From 6ba5f630e2c6f2885fec5e67ae38317491697081 Mon Sep 17 00:00:00 2001 From: Matt Christiansen Date: Wed, 1 Sep 2021 08:21:16 -0700 Subject: [PATCH] Prevent status updates from triggering reconcile loops (#385) Signed-off-by: Matt Christiansen Co-authored-by: anishakj <43978302+anishakj@users.noreply.github.com> --- .../zookeepercluster/zookeepercluster_controller.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/controller/zookeepercluster/zookeepercluster_controller.go b/pkg/controller/zookeepercluster/zookeepercluster_controller.go index e59e8af19..b2c9b2e9e 100644 --- a/pkg/controller/zookeepercluster/zookeepercluster_controller.go +++ b/pkg/controller/zookeepercluster/zookeepercluster_controller.go @@ -16,6 +16,7 @@ import ( "strconv" "time" + "github.com/operator-framework/operator-sdk/pkg/predicate" "k8s.io/client-go/kubernetes/scheme" "sigs.k8s.io/controller-runtime/pkg/client/fake" @@ -71,7 +72,7 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error { // Watch for changes to primary resource ZookeeperCluster err = c.Watch(&source.Kind{Type: &zookeeperv1beta1.ZookeeperCluster{}}, - &handler.EnqueueRequestForObject{}) + &handler.EnqueueRequestForObject{}, predicate.GenerationChangedPredicate{}) if err != nil { return err } @@ -79,7 +80,7 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error { err = c.Watch(&source.Kind{Type: &appsv1.StatefulSet{}}, &handler.EnqueueRequestForOwner{ IsController: true, OwnerType: &zookeeperv1beta1.ZookeeperCluster{}, - }) + }, predicate.GenerationChangedPredicate{}) if err != nil { return err } @@ -87,7 +88,7 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error { err = c.Watch(&source.Kind{Type: &corev1.Service{}}, &handler.EnqueueRequestForOwner{ IsController: true, OwnerType: &zookeeperv1beta1.ZookeeperCluster{}, - }) + }, predicate.GenerationChangedPredicate{}) if err != nil { return err } @@ -95,7 +96,7 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error { err = c.Watch(&source.Kind{Type: &corev1.Pod{}}, &handler.EnqueueRequestForOwner{ IsController: true, OwnerType: &zookeeperv1beta1.ZookeeperCluster{}, - }) + }, predicate.GenerationChangedPredicate{}) if err != nil { return err }