Skip to content

Commit

Permalink
Differentiate between the two enqueue functions
Browse files Browse the repository at this point in the history
Signed-off-by: Jonathan West <jonwest@redhat.com>
  • Loading branch information
jgwest committed Jun 25, 2024
1 parent 092d1b1 commit a4cc4b9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions controllers/argorollouts_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func (r *RolloutManagerReconciler) SetupWithManager(mgr ctrl.Manager) error {
// If the .spec of any RolloutManager changes (or a RM is created/deleted), inform the other RolloutManagers on the cluster
bld.Watches(
&rolloutsmanagerv1alpha1.RolloutManager{},
handler.EnqueueRequestsFromMapFunc(r.queueOtherRolloutManagers),
handler.EnqueueRequestsFromMapFunc(r.enqueueOtherRolloutManagersExceptObj),
builder.WithPredicates(predicate.Or(predicate.GenerationChangedPredicate{}, createdOrDeletedPredicate())))

// Watch for changes to ConfigMap sub-resources owned by RolloutManager.
Expand Down Expand Up @@ -226,11 +226,14 @@ func createdOrDeletedPredicate() predicate.Predicate {
}
}

func (r *RolloutManagerReconciler) queueOtherRolloutManagers(context context.Context, obj client.Object) []reconcile.Request {
// enqueueOtherRolloutManagersExceptObj will queue other RolloutManagers on the cluster, excluding the object itself.
// This is different from 'enqueueAllRolloutManagers': 'enqueueAllRolloutManagers' will not filter out the object itself.
func (r *RolloutManagerReconciler) enqueueOtherRolloutManagersExceptObj(context context.Context, obj client.Object) []reconcile.Request {

// List all other RolloutMangers on the cluster
rmList := rolloutsmanagerv1alpha1.RolloutManagerList{}
if err := r.List(context, &rmList); err != nil {
log.Error(err, "Unable to list all RolloutManagers in queueOtherRolloutManagers")
return []reconcile.Request{}
}

Expand Down

0 comments on commit a4cc4b9

Please sign in to comment.