Honor stderrthreshold when logtostderr is enabled#354
Closed
pierluigilenoci wants to merge 1 commit into
Closed
Conversation
|
I'll analyze this and get back to you. |
When logtostderr is true (the default), klog historically ignored
stderrthreshold, silently dropping log messages that should have been
written to stderr.
This was fixed in klog v2.140.0 by introducing a new flag
legacy_stderr_threshold_behavior. Setting it to false makes klog
honour stderrthreshold regardless of logtostderr.
This PR opts into the fixed behavior by calling:
flag.Set("legacy_stderr_threshold_behavior", "false")
flag.Set("stderrthreshold", "INFO")
right after klog.InitFlags(nil), so that all severity levels above
INFO are still printed to stderr by default but operators can now
filter using --stderrthreshold.
Ref: kubernetes/klog#212, kubernetes/klog#432
Signed-off-by: Pierluigi Lenoci <pierluigi.lenoci@gmail.com>
2df1ba3 to
32317f8
Compare
Contributor
Author
|
Hi @wallyqs @Jarema @samuelattwood — this PR has been rebased and is ready for review. It's a small fix to honor the Would you be able to take a look when you get a chance? Happy to address any feedback. Thank you! |
Contributor
Author
|
Hi @Jarema — friendly ping on this PR. It fixes the klog stderrthreshold behavior when logtostderr is enabled. Happy to address any feedback. Thanks! |
Contributor
Author
|
Closing in favor of #360, which addresses the same fix with a cleaner approach and has been approved by a maintainer. Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Opt into the new klog v2.140.0 behavior so that
-stderrthresholdis honored even when-logtostderr=true(the default). This fixes the long-standing klog bug (kubernetes/klog#212) where the stderrthreshold flag was silently ignored.Changes
k8s.io/klog/v2from v2.130.1 to v2.140.0legacy_stderr_threshold_behavior=falseandstderrthreshold=INFOprogrammatically afterklog.InitFlags(nil)--stderrthreshold=INFO, all log levels still go to stderr as before--stderrthreshold=WARNING(orERROR) to actually filter out lower-severity messages from stderrReferences
Supersedes #352 (recreated to fix CI checkout issue with fork branches).