@@ -86,6 +86,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ctrl.Re
86
86
return ctrl.Result {}, client .IgnoreNotFound (err )
87
87
}
88
88
89
+ klog .V (2 ).Infof ("DEBUG: Starting reconciliation for OperandRequest: %s/%s" , req .Namespace , req .Name )
89
90
originalInstance := requestInstance .DeepCopy ()
90
91
91
92
// Always attempt to patch the status after each reconciliation.
@@ -270,6 +271,7 @@ func (r *Reconciler) checkFinalizer(ctx context.Context, requestInstance *operat
270
271
func (r * Reconciler ) getRegistryToRequestMapper () handler.MapFunc {
271
272
ctx := context .Background ()
272
273
return func (object client.Object ) []ctrl.Request {
274
+ klog .V (2 ).Infof ("DEBUG: OperandRequest reconciliation triggered by OperandRegistry: %s/%s" , object .GetNamespace (), object .GetName ())
273
275
requestList , _ := r .ListOperandRequestsByRegistry (ctx , types.NamespacedName {Namespace : object .GetNamespace (), Name : object .GetName ()})
274
276
275
277
requests := []ctrl.Request {}
@@ -284,6 +286,7 @@ func (r *Reconciler) getRegistryToRequestMapper() handler.MapFunc {
284
286
285
287
func (r * Reconciler ) getSubToRequestMapper () handler.MapFunc {
286
288
return func (object client.Object ) []ctrl.Request {
289
+ klog .V (2 ).Infof ("DEBUG: OperandRequest reconciliation triggered by Subscription: %s/%s" , object .GetNamespace (), object .GetName ())
287
290
reg , _ := regexp .Compile (`^(.*)\.(.*)\.(.*)\/request` )
288
291
annotations := object .GetAnnotations ()
289
292
var reqName , reqNamespace string
@@ -309,6 +312,7 @@ func (r *Reconciler) getSubToRequestMapper() handler.MapFunc {
309
312
func (r * Reconciler ) getConfigToRequestMapper () handler.MapFunc {
310
313
ctx := context .Background ()
311
314
return func (object client.Object ) []ctrl.Request {
315
+ klog .V (2 ).Infof ("DEBUG: OperandRequest reconciliation triggered by OperandConfig: %s/%s" , object .GetNamespace (), object .GetName ())
312
316
requestList , _ := r .ListOperandRequestsByConfig (ctx , types.NamespacedName {Namespace : object .GetNamespace (), Name : object .GetName ()})
313
317
314
318
requests := []ctrl.Request {}
@@ -324,6 +328,7 @@ func (r *Reconciler) getConfigToRequestMapper() handler.MapFunc {
324
328
func (r * Reconciler ) getReferenceToRequestMapper () handler.MapFunc {
325
329
ctx := context .Background ()
326
330
return func (object client.Object ) []ctrl.Request {
331
+ klog .V (2 ).Infof ("DEBUG: OperandRequest reconciliation potentially triggered by referenced object: %s/%s" , object .GetNamespace (), object .GetName ())
327
332
annotations := object .GetAnnotations ()
328
333
if annotations == nil {
329
334
return []ctrl.Request {}
@@ -364,34 +369,44 @@ func (r *Reconciler) SetupWithManager(mgr ctrl.Manager) error {
364
369
ReferencePredicates := predicate.Funcs {
365
370
CreateFunc : func (e event.CreateEvent ) bool {
366
371
labels := e .Object .GetLabels ()
372
+ result := false
367
373
// only return true when both conditions are met at the same time:
368
374
// 1. label contain key "constant.ODLMWatchedLabel" and value is true
369
375
// 2. label does not contain key "constant.OpbiTypeLabel" with value "copy"
370
376
if labels != nil {
371
377
if labelValue , ok := labels [constant .ODLMWatchedLabel ]; ok && labelValue == "true" {
372
378
if labelValue , ok := labels [constant .OpbiTypeLabel ]; ok && labelValue == "copy" {
373
- return false
379
+ result = false
380
+ } else {
381
+ result = true
374
382
}
375
- return true
376
383
}
377
384
}
378
- return false
385
+ if result {
386
+ klog .V (2 ).Infof ("DEBUG: ReferencePredicates CreateFunc passed for: %s/%s" , e .Object .GetNamespace (), e .Object .GetName ())
387
+ }
388
+ return result
379
389
},
380
390
UpdateFunc : func (e event.UpdateEvent ) bool {
381
391
// If the object is not updated except the ODLMWatchedLabel label or ODLMReferenceAnnotation annotation, return false
382
392
if ! r .ObjectIsUpdatedWithException (& e .ObjectOld , & e .ObjectNew ) {
383
393
return false
384
394
}
385
395
labels := e .ObjectNew .GetLabels ()
396
+ result := false
386
397
if labels != nil {
387
398
if labelValue , ok := labels [constant .ODLMWatchedLabel ]; ok && labelValue == "true" {
388
399
if labelValue , ok := labels [constant .OpbiTypeLabel ]; ok && labelValue == "copy" {
389
- return false
400
+ result = false
401
+ } else {
402
+ result = true
390
403
}
391
- return true
392
404
}
393
405
}
394
- return false
406
+ if result {
407
+ klog .V (2 ).Infof ("DEBUG: ReferencePredicates UpdateFunc passed for: %s/%s" , e .ObjectNew .GetNamespace (), e .ObjectNew .GetName ())
408
+ }
409
+ return result
395
410
},
396
411
DeleteFunc : func (e event.DeleteEvent ) bool {
397
412
return true
0 commit comments