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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
馃悰 Inject manager's logger instead of internal one #1289
馃悰 Inject manager's logger instead of internal one #1289
Conversation
Hi @timebertt. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
@@ -251,7 +251,7 @@ func (cm *controllerManager) SetFields(i interface{}) error { | |||
if _, err := inject.MapperInto(cm.mapper, i); err != nil { | |||
return err | |||
} | |||
if _, err := inject.LoggerInto(log, i); err != nil { | |||
if _, err := inject.LoggerInto(cm.logger, i); err != nil { |
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.
What a mess this is, so the log
variable is:
logf.RuntimeLog.WithName("manager")
where
->logf.RuntimeLog
islog.Log.WithName("controller-runtime")
where
->log.Log
isNewDelegatingLogger(NullLogger{})
And the managers logger is defaulted to logf.Log
So I think we should have the manager
default options.Logger
to what is currently the log
variable instead, right?
ALso, can you check if the log
variable is used by anything else and if not, remove it and move the construction of its logger into the managers log defaulting?
/ok-to-test
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.
Yes, valid point.
Changed the defaulting of the manager's logger to logf.RuntimeLog.WithName("manager")
and switched the remaining usages of the log
variable now.
Hope I got you right, PTAL
f782be1
to
b9197ef
Compare
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.
/lgtm
/approve
thanks!
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alvaroaleman, timebertt The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Before this PR, the manager injected the controller-runtime-internal logger into controllers, predicates and so on, that implemented the
inject.Logger
interface. This means, controllers and so on were provided with a logger which name is set tocontroller-runtime.manager
.I found this behaviour to be confusing, especially if you provided the manager with a custom logger via
manager.Options.Logger
(e.g. with a different top-level name).With this PR, the manager injects its own logger or the default one, if none is specified.