Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Konnect entities: entities enqueued via EnqueueRequestsFromMapFunc from changes on other entities are missing event predicates #939

Open
pmalek opened this issue Dec 18, 2024 · 0 comments · May be fixed by #948
Labels
bug Something isn't working
Milestone

Comments

@pmalek
Copy link
Member

pmalek commented Dec 18, 2024

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. KongConsumers belonging to that group.

This is done via EnqueueRequestsFromMapFunc e.g. in here:

func(b *ctrl.Builder) *ctrl.Builder {
return b.Watches(
&configurationv1beta1.KongConsumerGroup{},
handler.EnqueueRequestsFromMapFunc(
enqueueKongConsumerForKongConsumerGroup(cl),
),
)
},
for KongConsumerGroup.

This behavior is missing the predicates that are in place for enqueuing objects of the type in question itself: so in here KongConsumerGroups are enqueued for their own changes and filtered with objRefersToKonnectGatewayControlPlane in

func(b *ctrl.Builder) *ctrl.Builder {
return b.For(&configurationv1.KongConsumer{},
builder.WithPredicates(
predicate.NewPredicateFuncs(objRefersToKonnectGatewayControlPlane[configurationv1.KongConsumer]),
),
)
},
.

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]),
+                               ),
                        )
                },
        }

Operator Version

kubectl version

@pmalek pmalek added the bug Something isn't working label Dec 18, 2024
@pmalek pmalek added this to the KGO v1.5.x milestone Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant