Skip to content

Commit

Permalink
Merge pull request #2967 from openshift-cherrypick-robot/cherry-pick-…
Browse files Browse the repository at this point in the history
…2959-to-release-4.18

DFBUGS-1266: [release-4.18] odf-info: stop owning the odf-info configMap
  • Loading branch information
openshift-merge-bot[bot] authored Jan 15, 2025
2 parents 8e6ee17 + 95b1928 commit 7fedea3
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
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.

0 comments on commit 7fedea3

Please sign in to comment.