Description
Current Behavior
When an entity that can enqueue other entities undergoes an observed event (e.g. a change in KongConsumerGroup
) then the dependent objects are enqueued (e.g. KongConsumer
s belonging to that group.
This is done via EnqueueRequestsFromMapFunc
e.g. in here: https://github.com/Kong/gateway-operator/blob/8961e81924f0f020cb711ef50b4e4f78a9ec068f/controller/konnect/watch_kongconsumer.go#L63-L70 for KongConsumerGroup
.
This behavior is missing the predicates that are in place for enqueuing objects of the type in question itself: so in here KongConsumerGroup
s are enqueued for their own changes and filtered with objRefersToKonnectGatewayControlPlane
in https://github.com/Kong/gateway-operator/blob/8961e81924f0f020cb711ef50b4e4f78a9ec068f/controller/konnect/watch_kongconsumer.go#L38-L44.
These predicates should also be added when using EnqueueRequestsFromMapFunc
. Otherwise objects not referring to e.g. KonnectGatewayControlPlane
and which should be reconciled by KIC, are going to be enqueued by KGO.
Expected Behavior
When using EnqueueRequestsFromMapFunc
to enqueue dependent objects, all relevant predicates are in place to filter the requests only to be reconciled by KGO.
Proposed solution
Add predicates like so for all the types that enqueue objects of other type:
diff --git a/controller/konnect/watch_kongconsumer.go b/controller/konnect/watch_kongconsumer.go
index 385c9666..e8717699 100644
--- a/controller/konnect/watch_kongconsumer.go
+++ b/controller/konnect/watch_kongconsumer.go
@@ -66,6 +66,9 @@ func KongConsumerReconciliationWatchOptions(
handler.EnqueueRequestsFromMapFunc(
enqueueKongConsumerForKongConsumerGroup(cl),
),
+ builder.WithPredicates(
+ predicate.NewPredicateFuncs(objRefersToKonnectGatewayControlPlane[configurationv1beta1.KongConsumerGroup]),
+ ),
)
},
}