Honor stderrthreshold when logtostderr is enabled#1539
Conversation
|
Thank you so much for this! I am going to approve it, but could you please rebase on |
akutz
left a comment
There was a problem hiding this comment.
Please rebase on main instead of merging main into the PR.
Minimum allowed line rate is |
83350e9 to
5941506
Compare
|
@akutz Done! Rebased onto latest |
|
Hi @akutz — friendly follow-up: the rebase onto main is done (single commit, no merge commits) as you requested. Would you be able to re-approve when you get a chance? Thank you! |
5941506 to
0f2c0ef
Compare
052964a to
e33bb75
Compare
e33bb75 to
bccb2f6
Compare
klog v2 defaults -logtostderr to true, which silently ignores the -stderrthreshold flag — all log levels are unconditionally sent to stderr. Bump klog to v2.140.0 and opt into the fixed behavior in the web-console-validator binary by setting legacy_stderr_threshold_behavior=false and stderrthreshold=INFO. This preserves current output while letting users override via CLI flags. Ref: kubernetes/klog#212, kubernetes/klog#432 Signed-off-by: Pierluigi Lenoci <pierluigilenoci@gmail.com>
bccb2f6 to
bc3c913
Compare
|
Hi @akutz — rebased onto latest main to resolve the merge conflict. All previous feedback remains addressed (single commit, no merge commits). Would you be able to take another look when you get a chance? Thank you! |
What this PR does
Fixes the
-stderrthresholdflag so it is honored even when-logtostderr=true(the klog v2 default) in the web-console-validator binary.Problem
klog v2 defaults
-logtostderrtotrue. When this flag is active, the-stderrthresholdflag is silently ignored — all log messages (INFO, WARNING, ERROR, FATAL) are unconditionally written to stderr.This has been an open issue since 2020: kubernetes/klog#212.
Fix
PR kubernetes/klog#432 introduced the fix in klog v2.140.0. This PR:
legacy_stderr_threshold_behavior=falseandstderrthreshold=INFOafterklog.InitFlags(nil)incmd/web-console-validator/main.goSetting
stderrthreshold=INFOpreserves the current default behavior. Users can now override it on the command line and it will actually work.Note: The main controller binary (
main.go) does not callklog.InitFlagsand usesctrl.SetLogger(klog.Background())instead, so only the web-console-validator binary is affected.Changes
cmd/web-console-validator/main.go: Addflag.Set()calls afterklog.InitFlags(nil)go.mod/go.sum: Bumpk8s.io/klog/v2v2.130.1 → v2.140.0Ref: kubernetes/klog#212, kubernetes/klog#432