Honor stderrthreshold when logtostderr is enabled#3859
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
@googlebot I signed it. |
1 similar comment
|
@googlebot I signed it. |
|
I don't work on cAdvisor anymore. |
|
Thank you for letting me know, @dashpole! Could @vmarmol or @rjnagal point me to the right person to review this? I see @thaJeztah and @olyazavr have been active recently — would either of you be able to take a look? It's a small klog stderrthreshold fix. Thank you! |
|
Hi @dims — friendly ping on this PR. It fixes the klog stderrthreshold behavior when logtostderr is enabled. Happy to address any feedback. Thanks! |
73ee2d2 to
16cb7f4
Compare
|
Hi @dims — gentle reminder on this PR. It fixes the klog stderrthreshold behavior when logtostderr is enabled (same fix as adopted in other k8s ecosystem projects). Happy to address any feedback. Thanks! |
klog v2 defaults -logtostderr to true, which silently ignores the -stderrthreshold flag — all log levels are unconditionally sent to stderr. This makes it impossible for log-aggregation systems to filter by severity. Bump klog to v2.140.0 and opt into the fixed behavior by setting legacy_stderr_threshold_behavior=false and stderrthreshold=INFO across all binaries and test utilities. 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>
16cb7f4 to
7641307
Compare
|
Hi — friendly follow-up. CI is green and all checks pass. Would you be able to review 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).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. There is no way for users to filter which severity levels reach 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 via a new flag
legacy_stderr_threshold_behavior. This PR:legacy_stderr_threshold_behavior=falseandstderrthreshold=INFOafter everyklog.InitFlags()callSetting
stderrthreshold=INFOpreserves the current default behavior (all logs go to stderr). Users can now override it on the command line (e.g.,-stderrthreshold=WARNING) and it will actually work.Changes
cmd/cadvisor.go: Main binary entry pointclient/clientexample/main.go: Client exampleutils/oomparser/oomexample/main.go: OOM parser exampleintegration/runner/runner.go: Integration test runnerintegration/tests/api/test_utils.go: API test utilitiesintegration/tests/crio/test_utils.go: CRI-O test utilitiesintegration/tests/healthz/test_utils.go: Healthz test utilitiesgo.mod/go.sum: Bumpk8s.io/klog/v2v2.130.1 → v2.140.0Ref: kubernetes/klog#212, kubernetes/klog#432