Add Kind filter to EnqueueRequestForProviderConfig#909
Add Kind filter to EnqueueRequestForProviderConfig#909adamwg merged 2 commits intocrossplane:mainfrom
Conversation
📝 WalkthroughWalkthroughAdds Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@pkg/resource/enqueue_handlers.go`:
- Around line 73-82: Default an empty ProviderConfigReference kind to
"ProviderConfig" before applying the kind filter and cluster-scope detection:
after obtaining ref via pcr.GetProviderConfigReference() set a localKind =
ref.Kind (or "ProviderConfig" when ref.Kind == "") and then use that localKind
for the comparison against e.Kind and for the strings.HasPrefix(..., "Cluster")
check so events aren't dropped when ref.Kind is omitted; update the comparisons
around e.Kind, strings.HasPrefix(ref.Kind, "Cluster"), and the reconcile.Request
construction to reference the normalized localKind.
30c83be to
b5dfb20
Compare
ezgidemirel
left a comment
There was a problem hiding this comment.
Thanks for the PR @jakubramut! It solves the issue in a straightforward way with a backward-compatible API change.
|
Thank you for a review @ezgidemirel. |
Hi @jakubramut, in main we recently updated ci.yaml and removed the following lines: I suspect this change is causing the CI/protobuf-schemas failure you’re seeing. Could you please rebase your PR on top of main and see if that resolves it? |
Allows controllers to filter ProviderConfigUsage events by Kind, preventing incorrect lookups when multiple ProviderConfig types share the same usage resource. Signed-off-by: Jakub Ramut <ramut.jakub@gmail.com>
… filtering is enabled. Signed-off-by: Jakub Ramut <ramut.jakub@gmail.com>
b5dfb20 to
161d36a
Compare
Description of your changes
Adds an optional Kind field to EnqueueRequestForProviderConfig that allows controllers to filter ProviderConfigUsage events by the referenced ProviderConfig kind.
Why this is needed:
When a provider has multiple ProviderConfig types (e.g., namespaced ProviderConfig and cluster-scoped ClusterProviderConfig) that share the same ProviderConfigUsage resource, both controllers receive all events. This causes the wrong controller to attempt lookups and log spurious errors like:
cannot get ProviderConfig... ProviderConfig.azuread.m.upbound.io \"name\" not foundeven when the resource correctly references a ClusterProviderConfig.
How it works
How I tested
Based on
https://github.com/crossplane-contrib/provider-upjet-azureadusing a go.mod replaceProviderConfiglookupsRelated provider PR will follow once this change is released.
Fixes: crossplane-contrib/provider-upjet-azuread#267
I have:
earthly +reviewableto ensure this PR is ready for review.No, but I run:
backport release-x.ylabels to auto-backport this PR.Cannot do it, but ready do be added.
Need help with this checklist? See the cheat sheet.