Skip to content

Commit

Permalink
Prevent status updates from triggering reconcile loops (#385)
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Christiansen <[email protected]>

Co-authored-by: anishakj <[email protected]>
  • Loading branch information
nikore and anishakj authored Sep 1, 2021
1 parent 38a3da8 commit 6ba5f63
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -71,31 +72,31 @@ 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
}
// Watch for changes to zookeeper stateful-set secondary resources
err = c.Watch(&source.Kind{Type: &appsv1.StatefulSet{}}, &handler.EnqueueRequestForOwner{
IsController: true,
OwnerType: &zookeeperv1beta1.ZookeeperCluster{},
})
}, predicate.GenerationChangedPredicate{})
if err != nil {
return err
}
// Watch for changes to zookeeper service secondary resources
err = c.Watch(&source.Kind{Type: &corev1.Service{}}, &handler.EnqueueRequestForOwner{
IsController: true,
OwnerType: &zookeeperv1beta1.ZookeeperCluster{},
})
}, predicate.GenerationChangedPredicate{})
if err != nil {
return err
}
// Watch for changes to zookeeper pod secondary resources
err = c.Watch(&source.Kind{Type: &corev1.Pod{}}, &handler.EnqueueRequestForOwner{
IsController: true,
OwnerType: &zookeeperv1beta1.ZookeeperCluster{},
})
}, predicate.GenerationChangedPredicate{})
if err != nil {
return err
}
Expand Down

0 comments on commit 6ba5f63

Please sign in to comment.