Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

odf-info: stop owning the odf-info configMap #2959

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions controllers/storagecluster/odfinfoconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import (
ocsv1 "github.com/red-hat-storage/ocs-operator/api/v4/v1"
ocsv1a1 "github.com/red-hat-storage/ocs-operator/api/v4/v1alpha1"
"github.com/red-hat-storage/ocs-operator/v4/controllers/util"

"gopkg.in/yaml.v2"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
)

Expand Down Expand Up @@ -54,11 +54,6 @@ func (obj *odfInfoConfig) ensureCreated(r *StorageClusterReconciler, storageClus
mutex.Lock()
defer mutex.Unlock()
_, err = ctrl.CreateOrUpdate(r.ctx, r.Client, odfInfoConfigMap, func() error {
// Note: purposely setting OwnerRef instead of ControllerRef, which alongside MatchEveryOwner
// sent in to OwnsOptions in the ConfigMap Owns, guarantees relevant events will be triggered
if err = controllerutil.SetOwnerReference(storageCluster, odfInfoConfigMap, r.Scheme); err != nil {
return err
}
r.Log.Info("Creating or updating odf-info config map", odfInfoMapKind, client.ObjectKeyFromObject(odfInfoConfigMap))
odfInfoKey := obj.getOdfInfoKeyName(storageCluster)

Expand Down
10 changes: 9 additions & 1 deletion controllers/storagecluster/storagecluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,15 @@ func (r *StorageClusterReconciler) SetupWithManager(mgr ctrl.Manager) error {
Watches(&volumesnapshotv1.VolumeSnapshotClass{}, enqueueStorageClusterRequest).
Watches(&ocsv1.StorageProfile{}, enqueueStorageClusterRequest).
Watches(&ocsv1alpha1.StorageConsumer{}, enqueueStorageClusterRequest, builder.WithPredicates(storageConsumerStatusPredicate)).
Watches(&ocsv1.StorageClusterPeer{}, enqueueStorageClusterRequest, builder.WithPredicates(predicate.GenerationChangedPredicate{}))
Watches(&ocsv1.StorageClusterPeer{}, enqueueStorageClusterRequest, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
Watches(
&corev1.ConfigMap{},
enqueueStorageClusterRequest,
builder.WithPredicates(
util.NamePredicate(OdfInfoConfigMapName),
util.NamespacePredicate(r.OperatorNamespace),
),
)

if os.Getenv("SKIP_NOOBAA_CRD_WATCH") != "true" {
build.Owns(&nbv1.NooBaa{}, builder.WithPredicates(noobaaIgnoreTimeUpdatePredicate))
Expand Down
6 changes: 6 additions & 0 deletions controllers/util/predicates.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ func NamePredicate(name string) predicate.Predicate {
})
}

func NamespacePredicate(namespace string) predicate.Predicate {
return predicate.NewPredicateFuncs(func(obj client.Object) bool {
return obj.GetNamespace() == namespace
})
}

// EventTypePredicate return a predicate to filter events based on their
// respective event type. This helper allows for the selection of multiple
// types resulting in a predicate that can filter in more than a single event
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading