-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Consolidate controllers implementation to use scope objects #3517
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
Comments
@randomvariable can speak more for CAPA, mostly a personal opinion, but I'd rather find a better solution in controller-runtime that is generic and can setup things properly, rather than introduce scoped reconcilers which are hard to debug.
This is already being tackled in controller-runtime v0.7.x, each Reconciler will now accept a context.
Same as above, the Scope objects that we find today in CAPA/CAPV/CAPZ have definitely fulfilled their purpose, although they're one of those things that try to do too much and are hard to test. |
I'm not willing to introduce scoped reconcilers but to extend to CAPI the pattern of using scope object like in CAPA
That's interesting, but TBH, given that Log and ctx are already addressed, all the remaining bits are really CAPI/controllers specific, so I don't find something that can be generalized. |
Not yet, need to think through a little more :D
That's what I meant as well, I don't know if that's the best way forward, I like the simplicity of our controllers today /milestone Next |
Being able to add more keys to the logger and having them passed downstream would be great. I do have a branch of KCP that attempts to thread a logger all the way through everything. If ctx is going to have a logger, I guess that's fine. Otherwise, main benefits in CAPA have been having the well-formed AWS service clients and utility functions, but otherwise they've not lead to the cleanest code. CAPA's scopes have also been broken up into much smaller ones to accommodate the EKS implementation, so atm. |
Not only that, but you'll be able to enrich the logger when passing it down 😄
Do we now have tests for the scope objects as well? IIRC they were untested for a while |
I too would like to avoid extending the "scope" pattern further. It makes debugging more difficult, makes testing more difficult (what all do I need to populate in the scope as a bare minimum for testing this thing), and it tends to leak much further than the controller code and down into libraries as well. |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
/remove-lifecycle stale |
Now that we have the logger passed in with the context, we should be able to close this one out for now. As mentioned above, I don't think expanding the |
/close |
@fabriziopandini: Closing this issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
User Story
As a developer, I would like to have a simple way to pass objects throw the chain of
reconcile
funcs inside each controllerAs a developer, I would like to have a consistent implementation approach in different controllers
Detailed Description
If a look at controllers, as of today all the
reconcile
funcs are getting in input the same list of parameters, and in most cases, this list is composed by 3 or more objects.Patch
command in the middle of the reconcile logic, but given the above limitation, we are recreating the patch helper/reimplementing thePatch
call in many places instead of re-using that exists in the main reconcile loop, and this is risky due to the increasing number of patch options.log
parameter, and as a consequence, we are recreating the samelog.WithValues
in many placesIn order to address this problem I would like to discuss the option to introduce a scope object with the goal to provide a single object for passing along the
reconcile
funcs chain the following objects:ctx
)machine
,infraMachine
,bootstrapConfig
)log
instance with all theWithValues
keys for ^^patchHelper
for ^^The scope object should provide access to the above objects, expose the
Patch
method (thus ensuring the various patch options are defined in a single place).Additionally, the scope can implement some utility methods to handle the contained objects, like e.g. filters; by moving such details of object handling detail out of the reconcile loop, there is a concrete opportunity to clean up and make more readable reconcile logic in the main controller file.
WDYT?
Anything else you would like to add:
Scope objects are already used in CAPA
KCP has a controlplane object that acts as a scope object
/kind cleanup
The text was updated successfully, but these errors were encountered: