Skip to content

fix: opt into fixed klog stderrthreshold behavior#596

Open
pierluigilenoci wants to merge 3 commits intoFairwindsOps:masterfrom
pierluigilenoci:fix/honor-stderrthreshold
Open

fix: opt into fixed klog stderrthreshold behavior#596
pierluigilenoci wants to merge 3 commits intoFairwindsOps:masterfrom
pierluigilenoci:fix/honor-stderrthreshold

Conversation

@pierluigilenoci
Copy link
Copy Markdown

@pierluigilenoci pierluigilenoci commented Mar 26, 2026

Problem

klog v2 defaults -logtostderr to true. When this flag is active, the -stderrthreshold flag 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_behavior flag (kubernetes/klog#432). Setting it to false makes -stderrthreshold work correctly even when -logtostderr=true.

This PR opts pluto into the fixed behavior by setting legacy_stderr_threshold_behavior=false after klog.InitFlags() in cmd/root.go. The default stderrthreshold remains INFO so the observable behavior is unchanged — all logs still go to stderr by default. Users who want filtering can now pass -stderrthreshold=WARNING or -stderrthreshold=ERROR and it will actually take effect.

References

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 26, 2026

CLA assistant check
All committers have signed the CLA.

@pierluigilenoci
Copy link
Copy Markdown
Author

recheck

@pierluigilenoci
Copy link
Copy Markdown
Author

Gentle ping — could you take a look when you get a chance? All CI checks are green (the Publish Dev Orb failure is a known fork limitation, also present on other fork PRs like #589 and #581). This opts into the fixed klog stderrthreshold behavior per kubernetes/klog#212. Happy to address any feedback. Thank you!

@pierluigilenoci
Copy link
Copy Markdown
Author

Hi team — friendly follow-up. All CI checks are green except Publish Dev Orb, which is a known CircleCI fork limitation (same failure pattern seen on other fork PRs like #589 and #581).

This is a small change to opt into klog's fixed stderrthreshold behavior. Would appreciate a review when you get a chance. Thank you!

@pierluigilenoci pierluigilenoci force-pushed the fix/honor-stderrthreshold branch from 1b90cf1 to f0ae7fb Compare April 10, 2026 21:02
@pierluigilenoci
Copy link
Copy Markdown
Author

Hi @sudermanjr — friendly ping on this PR. It opts into the fixed klog stderrthreshold behavior. Happy to address any feedback. Thanks!

@pierluigilenoci pierluigilenoci force-pushed the fix/honor-stderrthreshold branch from f0ae7fb to 2eb2242 Compare April 21, 2026 19:58
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>
@pierluigilenoci
Copy link
Copy Markdown
Author

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!

pierluigilenoci and others added 2 commits May 2, 2026 15:52
Signed-off-by: Pierluigi Lenoci <pierluigilenoci@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants