Skip to content

Commit

Permalink
feat: add predicate to prevent reconcile again after updating
Browse files Browse the repository at this point in the history
  • Loading branch information
maxsxu committed Feb 18, 2022
1 parent c3acc76 commit a084d73
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion controllers/zookeepercluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
ctrl_log "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/predicate"

zookeeperv1alpha1 "github.com/jsonbruce/zookeeper-operator/api/v1alpha1"
)
Expand Down Expand Up @@ -336,6 +338,6 @@ func (r *ZookeeperClusterReconciler) createService(zk *zookeeperv1alpha1.Zookeep
// SetupWithManager sets up the controller with the Manager.
func (r *ZookeeperClusterReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&zookeeperv1alpha1.ZookeeperCluster{}).
For(&zookeeperv1alpha1.ZookeeperCluster{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
Complete(r)
}

0 comments on commit a084d73

Please sign in to comment.