fix: honor -stderrthreshold when -logtostderr=true#391
Open
pierluigilenoci wants to merge 1 commit intowerf:mainfrom
Open
fix: honor -stderrthreshold when -logtostderr=true#391pierluigilenoci wants to merge 1 commit intowerf:mainfrom
pierluigilenoci wants to merge 1 commit intowerf:mainfrom
Conversation
klog v2 defaults -logtostderr to true, which silently ignores -stderrthreshold — all severities are unconditionally sent to stderr. Bump klog to v2.140.0 and opt into the fixed behavior by setting legacy_stderr_threshold_behavior=false so that -stderrthreshold is respected. The default is set to INFO (preserving current behavior); users can now override it on the command line. Ref: kubernetes/klog#212, kubernetes/klog#432 Signed-off-by: Pierluigi Lenoci <pierluigi.lenoci@gmail.com> Signed-off-by: Pierluigi Lenoci <pierluigilenoci@gmail.com>
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.
What
Bump klog to v2.140.0 and opt into the fixed behavior so that
-stderrthresholdis respected even when-logtostderr=true(the default).Why
klog v2 defaults
-logtostderrtotrue. When active, the-stderrthresholdflag is silently ignored — all log severities are unconditionally written to stderr. This makes it impossible for log-aggregation systems to filter by severity.This has been an open issue since 2020: kubernetes/klog#212
The fix was merged in klog v2.140.0 via kubernetes/klog#432 (authored by me) and introduces an opt-in flag
legacy_stderr_threshold_behavior. Setting it tofalseenables the corrected behavior where-stderrthresholdis honored.What changes
cmd/kubedog/main.goSilenceKlog(), afterklog.InitFlags(fs),legacy_stderr_threshold_behavior=falseis set to ensure the existingstderrthresholdsetting is properly honored.References