fix: opt into fixed klog stderrthreshold behavior#596
fix: opt into fixed klog stderrthreshold behavior#596pierluigilenoci wants to merge 3 commits intoFairwindsOps:masterfrom
Conversation
|
recheck |
|
Gentle ping — could you take a look when you get a chance? All CI checks are green (the |
|
Hi team — friendly follow-up. All CI checks are green except This is a small change to opt into klog's fixed stderrthreshold behavior. Would appreciate a review when you get a chance. Thank you! |
1b90cf1 to
f0ae7fb
Compare
|
Hi @sudermanjr — friendly ping on this PR. It opts into the fixed klog stderrthreshold behavior. Happy to address any feedback. Thanks! |
f0ae7fb to
2eb2242
Compare
klog v2 defaults -logtostderr to true. When this flag is active, the -stderrthreshold flag is silently ignored — all log messages are unconditionally written to stderr regardless of severity. Opt into the fixed behavior introduced in klog v2.140.0 by setting legacy_stderr_threshold_behavior=false. The default stderrthreshold remains INFO so the observable behavior is unchanged — users who want filtering can now pass -stderrthreshold=WARNING and it will take effect. Ref: kubernetes/klog#212, kubernetes/klog#432 Signed-off-by: Pierluigi Lenoci <pierluigilenoci@gmail.com>
2eb2242 to
bb46051
Compare
|
Hi @transient1, @jdesouza — I see you're both active contributors on Pluto (and @transient1 is listed in CODEOWNERS). Would you be able to take a look at this PR when you get a chance? Happy to make any changes if needed. Thanks! |
Signed-off-by: Pierluigi Lenoci <pierluigilenoci@gmail.com>
Problem
klog v2 defaults
-logtostderrtotrue. When this flag is active, the-stderrthresholdflag is silently ignored — all log messages of every severity (INFO, WARNING, ERROR, FATAL) are unconditionally written to stderr.This makes it impossible for log-aggregation systems (Fluentd, Fluent Bit, Loki, Datadog, etc.) to filter logs by severity on the stderr stream.
This has been an open issue since 2020: kubernetes/klog#212
Fix
klog v2.140.0 introduced a new
legacy_stderr_threshold_behaviorflag (kubernetes/klog#432). Setting it tofalsemakes-stderrthresholdwork correctly even when-logtostderr=true.This PR opts pluto into the fixed behavior by setting
legacy_stderr_threshold_behavior=falseafterklog.InitFlags()incmd/root.go. The defaultstderrthresholdremainsINFOso the observable behavior is unchanged — all logs still go to stderr by default. Users who want filtering can now pass-stderrthreshold=WARNINGor-stderrthreshold=ERRORand it will actually take effect.References