-
Notifications
You must be signed in to change notification settings - Fork 135
Add Kind filter to EnqueueRequestForProviderConfig #909
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
base: main
Are you sure you want to change the base?
Add Kind filter to EnqueueRequestForProviderConfig #909
Conversation
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>
📝 WalkthroughWalkthroughAdds a Changes
Sequence Diagram(s)mermaid Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
… filtering is enabled. Signed-off-by: Jakub Ramut <ramut.jakub@gmail.com>
30c83be to
b5dfb20
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.