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
OCPBUGS-23161: Set logging for controller-runtime #2129
Conversation
Hi @arghosh93. Thanks for your PR. I'm waiting for a openshift 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. |
/ok-to-test |
@kyrtapz: The label(s) 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. |
Call SetLogger before adding controller-runtime client to prevent controller-runtime complaining about it after 30 seconds of binaries lifetime https://github.com/kubernetes-sigs/controller-runtime/blob/main/pkg/log/log.go#L54 JIRA: https://issues.redhat.com/browse/OCPBUGS-23161 Signed-off-by: Arnab Ghosh <arnabghosh89@gmail.com>
ba37f22
to
d7e0f33
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 (the fix makes sense based on the stack trace of the panic I did)
thanks @arghosh93 !!
/assign @kyrtapz for a second opinion
@tssurya: GitHub didn't allow me to assign the following users: second, opinion, for, a. Note that only openshift members with read permissions, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time. 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. |
/retest |
@arghosh93: This pull request references Jira Issue OCPBUGS-23161, which is invalid:
Comment The bug has been updated to refer to the pull request using the external bug tracker. 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. |
/jira refresh |
@tssurya: This pull request references Jira Issue OCPBUGS-23161, which is valid. 3 validation(s) were run on this bug
Requesting review from QA contact: 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. |
// Call SetLogger before adding controller-runtime client to prevent controller-runtime | ||
// complaining about it after 30 seconds of binaries lifetime | ||
// https://github.com/kubernetes-sigs/controller-runtime/blob/main/pkg/log/log.go#L54 | ||
ctlog.SetLogger(logger) |
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.
I don't think we should be setting the root logger in a function.
This should be done once, somewhere in main.
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.
hmm isn't RunOperator
only called once from main?
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.
do you think
func main() {
pflag.CommandLine.SetNormalizeFunc(utilflag.WordSepNormalizeFunc)
pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
logs.InitLogs()
defer logs.FlushLogs()
command := newNetworkOperatorCommand()
if err := command.Execute(); err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(1)
}
}
is a better spot?
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.
I confused the functions, apologies.
In that case I am fine to keep this in RunOperator as this is the main entry-point of CNO anyway.
Although somewhere around the following would be perfect:
func main() {
pflag.CommandLine.SetNormalizeFunc(utilflag.WordSepNormalizeFunc)
pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
logs.InitLogs()
defer logs.FlushLogs()
<HERE>
}
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, RunOperator only gets called once from main. I was little bit worried about hard coded condition of initializing SetLogger within 30 second of binary's lifetime and thats why I have put it in RunOperator instead of main.
https://github.com/kubernetes-sigs/controller-runtime/blob/main/pkg/log/log.go#L54
I have also tested by initializing the logger just before command.Execute() in main and that would also resolve the panic.
/retest |
/lgtm |
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.
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: arghosh93, kyrtapz, trozet, tssurya 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 |
@arghosh93: The following tests failed, say
Full PR test history. Your PR dashboard. 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 understand the commands that are listed here. |
c212e31
into
openshift:master
@arghosh93: Jira Issue OCPBUGS-23161: All pull requests linked via external trackers have merged: Jira Issue OCPBUGS-23161 has been moved to the MODIFIED state. 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. |
[ART PR BUILD NOTIFIER] This PR has been included in build cluster-network-operator-container-v4.16.0-202312070751.p0.gc212e31.assembly.stream for distgit cluster-network-operator. |
Fix included in accepted release 4.15.0-0.nightly-2023-12-07-225558 |
Call SetLogger before adding controller-runtime client to prevent controller-runtime complaining about it after 30 seconds of binaries lifetime.
https://github.com/kubernetes-sigs/controller-runtime/blob/main/pkg/log/log.go#L54
JIRA: https://issues.redhat.com/browse/OCPBUGS-23161