Bug Description
When --logtostderr is enabled (Velero's default), the --stderrthreshold flag is silently ignored due to a legacy behavior in klog. This means all log levels (INFO, WARNING, ERROR) are always written to stderr regardless of the --stderrthreshold setting.
This was identified as a bug in kubernetes/klog#432 and fixed in klog v2.140.0 by introducing a new behavior mode that must be explicitly opted into.
Steps to Reproduce
- Start Velero server with
--stderrthreshold=WARNING (attempting to only see warnings and errors on stderr)
- Observe that INFO messages still appear on stderr
- The flag has no effect because
--logtostderr=true (the default) bypasses the threshold check
Expected Behavior
When --stderrthreshold=WARNING is set, only WARNING and ERROR level messages should appear on stderr. INFO messages should be suppressed from stderr output.
Actual Behavior
All log levels (INFO, WARNING, ERROR) appear on stderr regardless of the --stderrthreshold setting, because the legacy klog behavior ignores the threshold when logtostderr is true.
Fix
- Bump
k8s.io/klog/v2 to v2.140.0
- Set
legacy_stderr_threshold_behavior=false after klog.InitFlags() to opt into the fixed behavior
- Set
stderrthreshold=INFO to maintain current behavior (all logs to stderr) while making the flag actually functional for users who want to customize it
References
Bug Description
When
--logtostderris enabled (Velero's default), the--stderrthresholdflag is silently ignored due to a legacy behavior in klog. This means all log levels (INFO, WARNING, ERROR) are always written to stderr regardless of the--stderrthresholdsetting.This was identified as a bug in kubernetes/klog#432 and fixed in klog v2.140.0 by introducing a new behavior mode that must be explicitly opted into.
Steps to Reproduce
--stderrthreshold=WARNING(attempting to only see warnings and errors on stderr)--logtostderr=true(the default) bypasses the threshold checkExpected Behavior
When
--stderrthreshold=WARNINGis set, only WARNING and ERROR level messages should appear on stderr. INFO messages should be suppressed from stderr output.Actual Behavior
All log levels (INFO, WARNING, ERROR) appear on stderr regardless of the
--stderrthresholdsetting, because the legacy klog behavior ignores the threshold whenlogtostderris true.Fix
k8s.io/klog/v2to v2.140.0legacy_stderr_threshold_behavior=falseafterklog.InitFlags()to opt into the fixed behaviorstderrthreshold=INFOto maintain current behavior (all logs to stderr) while making the flag actually functional for users who want to customize itReferences