-
Notifications
You must be signed in to change notification settings - Fork 433
chore(controllers): Use req.NamespacedName
directly
#2025
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
Conversation
req.NamespacedName
directly
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.
Not like I perfectly know the internals, but, to me, the change around removal of the scheme does not look right. Even though it's the same across resources, it still needs to be properly propagated from the same instance: scheme = runtime.NewScheme()
-> .AddToScheme
calls in init()
-> Reconcilers.
Here, the Scheme()
gets inherited from Client
interface, where it's defined as Scheme() *runtime.Scheme
meaning it does not appear to be set to the real scheme where all our custom APIs are registered.
And having Scheme *runtime.Scheme
as part of any reconciler definition is a common pattern anyway.
So, without extra comments from your side explaining why you think the change is safe, I feel like the change should not be made.
I went digging through the implementation of the Manager struct to triple-check this. We init the scheme exactly as you wrote above, but we never instantiate an API client. Lines 185 to 189 in 129224e
Lines 259 to 263 in 129224e
The We see
Which define the GetClient and GetScheme functions Used in our main.go to build and register the controllers: Lines 265 to 274 in 129224e
TLDR: |
The above comment does not address whether this is a good change. I'm not against dropping the commit with the Scheme changes if we decide it's not worth it. |
9e5a251
to
6567be0
Compare
Thanks for the explanation! Personally, I would rather favour leaving the existing code around Schema as it matches things described in the kubebuilder book, operator-sdk scaffolding, and other places. If other maintainers think the change should be accepted, I'm OK with that, so let's just wait for others to vote on this :) |
We talked about this in the weekly call and decided to keep the scheme. The |
Sounds good, I'll drop the commit later today. |
6567be0
to
368acbf
Compare
req.NamespacedName
directlyreq.NamespacedName
directly
This removes all the places we store a pointer to the scheme unnecessarily and refactors the controllers to use the
req.NamespacedName
when fetching the resource in the beginning of all Reconcile functions.