-
Notifications
You must be signed in to change notification settings - Fork 219
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
InitFlags does not reset klog configuration if application already did logging #67
Comments
Having call to algorithmprovider.ApplyFeatureGates() in module init function was problematic as the mathod calls out to klog.Infof(). The call to klog.Infof() was then happening before klog related application flags were parsed which resulted in klog misbehavior. See kubernetes/klog#67.
Unless I'm mistaken |
Having call to algorithmprovider.ApplyFeatureGates() in module init function was problematic as the mathod calls out to klog.Infof(). The call to klog.Infof() was then happening before klog related application flags were parsed which resulted in klog misbehavior. See kubernetes/klog#67.
yeah, initflags should always be one of the first things you call in your program. |
Yeah - and it was in my case - the logging was done deep in the stack in the function called from one of the module Init() funs (which are called before main() entrypoint). |
ah, hmm... that's problematic |
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 Unless fixed this is still problematic issue. |
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. |
Stale issues rot after 30d 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 |
/priority important-longterm |
I have tested the Double-check in source code, Line 930 in 02ca14b
seems we could close this issue now. |
Having call to algorithmprovider.ApplyFeatureGates() in module init function was problematic as the mathod calls out to klog.Infof(). The call to klog.Infof() was then happening before klog related application flags were parsed which resulted in klog misbehavior. See kubernetes/klog#67.
/kind bug
What steps did you take and what happened:
klog.InitFlags(nil)
andflag.Parse()
. Flags specify log file.What did you expect to happen:
Ideally klog should properly reinitialize itself to configuration specified via flags on (4) and log from (5) should be appended to the log file.
Alternatively klog could disallows calling InitFlag() after logging was done before (panic?).
Yet this is suboptimal as one not always can prevent logging from happening before InitFlags. As logging can occur in init function of some dependent module.
Anything else you would like to add:
The source of described problem lies in behavior of
createFiles
(https://github.com/kubernetes/klog/blob/master/klog.go#L968). This method is called on first logging and log appenders are created then and put in logging.files array. Those are not reset later even if configuration changes.Actually the situation is even more confusing than that. As appenders are created only for log levels up to requested one, we end up in inconsistent state of klog in following sequence of events:
Then the appenders for DEBUG and INFO will be based on default configuration. And appender for ERROR will take configuration changes from flags into account.
I spotted the problem when playing with flag related to log file but possibly one can run into issues with other flags too.
The text was updated successfully, but these errors were encountered: