Skip to content

fix: opt into fixed klog stderrthreshold behavior - #636

Open
pierluigilenoci wants to merge 1 commit into
FairwindsOps:masterfrom
pierluigilenoci:fix/honor-stderrthreshold-v2
Open

pierluigilenoci wants to merge 1 commit into
FairwindsOps:masterfrom
pierluigilenoci:fix/honor-stderrthreshold-v2

Conversation

@pierluigilenoci

@pierluigilenoci pierluigilenoci commented Dec 3, 2026 •

Copy link
Copy Markdown

Summary

When -logtostderr=true (klog's default since v2.0), the -stderrthreshold flag is silently ignored. This was a known klog bug fixed in klog v2.140.0 via the legacy_stderr_threshold_behavior flag.

This PR opts into the fixed behavior by setting legacy_stderr_threshold_behavior=false early in initialization, before flag.Parse(). Setting stderrthreshold=INFO preserves the existing behavior (all logs still appear on stderr by default).

Users can now control stderr log verbosity by passing -stderrthreshold=WARNING or -stderrthreshold=ERROR to suppress lower-severity log lines on stderr.

Changes

  • cmd/root.go: call flag.Set("legacy_stderr_threshold_behavior", "false") and flag.Set("stderrthreshold", "INFO") right after klog.InitFlags(nil), before flag.Parse()

Recreated from the original PR #596, which was closed by the stale bot.

When -logtostderr=true (klog's default since v2.0), the -stderrthreshold
flag is silently ignored. This was a known klog bug (kubernetes/klog#212)
fixed in klog v2.140.0 via the legacy_stderr_threshold_behavior flag.

Opt into the fixed behavior by setting legacy_stderr_threshold_behavior=false
early in initialization, before flag.Parse(). Setting stderrthreshold=INFO
preserves the existing behavior (all logs still appear on stderr by default).

Users can now control stderr log verbosity by passing -stderrthreshold=WARNING
or -stderrthreshold=ERROR to suppress lower-severity log lines on stderr.

This branch has not been deployed

No deployments
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.

1 participant