-
Notifications
You must be signed in to change notification settings - Fork 42
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
Prune logging cannot be set #99
Comments
The codes shared from operator-lib came from old implementations. What exactly is required to do here? Just change the lib imported?
This shows that the idea is to apply/run the prune configuration. Would |
…e library strategy.
this (and the linked PR) seems good. I don't seem to have permissions over in operator-lib, though. |
@fgiloux instead of using a new global logger, would it be possible to pull the logger from the |
@joelanford isn't it making the assumption that the library functions would be called from the reconcile loop? This may not be the case. The initial author mentioned that it may be called from a cron package: https://sdk.operatorframework.io/docs/best-practices/resource-pruning/#pruning-execution |
Yeah, I'm generally always in the Dave Cheney camp, and I would typically be on this topic as well. I think the reasons I favor the context approach over the global approach in this case are:
Perhaps in Another option would just be to make Having said all that. I don't feel so strongly that the PR should be blocked. If I've convinced you, great! If not, feel free to unhold the PR. |
@joelanford Thanks for the input. I have reworked the pull request. I am not fully happy with the result but I hope that it is an acceptable state till some redesign comes from Ryan's enhancement proposal.
One consequence of the context approach is that there is still no compile time check. The lack of key validation is mitigated by the fact that there is a canonical way provided by logr to set and retrieve the logger from context: |
Bug Report
What did you do?
Wanting to configure the Prune structure but the log field is not exported and never set.
What did you expect to see?
Either that the field is automatically populated or that it is exported.
What did you see instead? Under which circumstances?
A field that is not exported and not automatically set.
Possible Solution
Although, I am not in favor of using global variables for loggers things should be consistent inside a library. The other features provided by operator-lib for instance event handler and leader election use a preset variable:
logf is a package of the controller-runtime library, which contains logr.Logger Log. This assumes that SetLogger was called earlier, which is the same expectation sets by Kubebuilder/controller-runtime.
This makes this library less suitable for clients or other apps not based on controller-runtime but again things should be consistent.
Another thing I would like to mention and a second issue could get open for it is that the naming/structure could be improved. It seems a bit unconventional to have a method like Execute on a structure named Config. I would expect that more on a structure called Pruner. Config being what is provided by users to get Pruners that fits their needs.
The text was updated successfully, but these errors were encountered: