-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Reconcile methods should take a context and logger #801
Comments
@vincepri This sounds like it's already part of a solution, could you elaborate a bit on the problem/use case?
As an implementation detail comment, this could be implemented backwards compatible by adding a new interface, checking via type assertion if the reconciler implements it and if yes use that rather than the existing reconcile. |
Was planning on discussing at the next community meeting, the main use case is to ease adoption and reduce boilerplate. If we look at a sample of controller-runtime implementations, pretty much all of them define a logger and context at the very top of the function.
There is another issue around a global timeout (#798), which could be useful in this case. In alternative, we can start with a simple context that has no deadline, and see how things go from there. I'd like to hear more feedback from the wild on this.
I'd like to start with a logger that has the reconciled object type, name, and namespace.
This doesn't change from what we have today, which is the ability to set the global klogr logger in CR's
Definitely a possibility. We should definitely explore more solutions. That said, having one interface to maintain is probably easier, cleaner, and more consistent. |
/milestone breaking-next |
/kind design |
@vincepri: Please ensure the request meets the requirements listed here. If this request no longer meets these requirements, the label can be removed 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. |
I'm a little more keen on the Reconciles method taking a context than I am with it taking the logger.
I didn't know about this. In the case that logger was included in the Reconcile methods this particular aspect (being able to choose your own logger) should be called out as best as possible in docs. |
Looking through a couple of controllers that I've been a part of writing and I'm seeing a lot of I'm looking forward to the discussion in the next community meeting to better understand the value proposition. |
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. |
/lifecycle frozen |
@vincepri any update on this? How did the community meeting discussion go?
I think this could actually be a fair and straightforward alternative. It's easy for the user to see that "here's my pre-defined logger, which I can use if I want to". The decision I think depends on if we know of anything else we'd like to provide the controllers. #798 would be nice to solve in some way, to be able to set a global deadline. The manager could also e.g. close the ctx given to the reconciler loop upon a Ctrl-C signal. We could just say "if Reconcile doesn't respect the context and deadlocks, you're violating the contract", with the tradeoff that if a reconcile loop doesn't follow the contract, there might be multiple executing reconcile loops at the same time (optionally; guaranteed to never run two Reconcile loops twice for the same |
There was some consensus on getting this implemented with a simple breaking change to the current API, given that's a breaking change we'd have to wait for the next release. Happy to contribute it (I'll probably be available for this ~2 week), or review it if someone wants to tackle it. |
So, in other words, the first option with just adding context and logger to the signature?
that is, v0.6.0 or v0.7.0? |
Yeah, either that or a single struct that has multiple fields (like Log) and implements
It'd be for v0.7, given that v0.6 has already been released |
I could take a stab at a PoC PR of this if nobody else can. |
Ah cool 👍 |
/close This has been implemented |
@vincepri: 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. |
We can have different solutions to this issue, but it's going to be indeed a breaking change.
A few ideas to discuss:
ctrl.Context
, should always satisfycontext.Context
interface.The text was updated successfully, but these errors were encountered: