@@ -267,47 +267,33 @@ func (r *Reconciler) SetupWithManager(mgr ctrl.Manager) error {
267267 }
268268
269269 isManagedResource := func (object client.Object ) bool {
270- return object .GetLabels () != nil && object .GetLabels ()[requestEnqueueLabelKey ] == requestEnqueueLabelValue
271- }
272-
273- logIgnored := func (obj client.Object ) {
274- r .log .V (4 ).Info ("object not of interest, ignoring reconcile event" , "object" , fmt .Sprintf ("%T" , obj ), "name" , obj .GetName (), "namespace" , obj .GetNamespace ())
270+ labels := object .GetLabels ()
271+ matches := labels != nil && labels [requestEnqueueLabelKey ] == requestEnqueueLabelValue
272+ r .log .V (4 ).Info ("predicate evaluation" , "object" , fmt .Sprintf ("%T" , object ), "name" , object .GetName (), "namespace" , object .GetNamespace (), "labels" , labels , "matches" , matches )
273+ return matches
275274 }
276275
277276 // On updates, check both old and new objects so that events where the managed
278277 // label is removed externally still trigger reconciliation and label restoration.
279278 managedResources := predicate.Funcs {
280279 CreateFunc : func (e event.CreateEvent ) bool {
281- if ! isManagedResource (e .Object ) {
282- logIgnored (e .Object )
283- return false
284- }
285- return true
280+ return isManagedResource (e .Object )
286281 },
287282 UpdateFunc : func (e event.UpdateEvent ) bool {
288- if ! isManagedResource (e .ObjectOld ) && ! isManagedResource (e .ObjectNew ) {
289- logIgnored (e .ObjectNew )
290- return false
291- }
292- return true
283+ return isManagedResource (e .ObjectOld ) || isManagedResource (e .ObjectNew )
293284 },
294285 DeleteFunc : func (e event.DeleteEvent ) bool {
295- if ! isManagedResource (e .Object ) {
296- logIgnored (e .Object )
297- return false
298- }
299- return true
286+ return isManagedResource (e .Object )
300287 },
301288 GenericFunc : func (e event.GenericEvent ) bool {
302- if ! isManagedResource (e .Object ) {
303- logIgnored (e .Object )
304- return false
305- }
306- return true
289+ return isManagedResource (e .Object )
307290 },
308291 }
309292
310- withIgnoreStatusUpdatePredicates := builder .WithPredicates (predicate.GenerationChangedPredicate {}, managedResources )
293+ withIgnoreStatusUpdatePredicates := builder .WithPredicates (
294+ predicate .Or (predicate.GenerationChangedPredicate {}, predicate.LabelChangedPredicate {}),
295+ managedResources ,
296+ )
311297 managedResourcePredicate := builder .WithPredicates (managedResources )
312298
313299 mgrBuilder := ctrl .NewControllerManagedBy (mgr ).
0 commit comments