fix: honor -stderrthreshold when -logtostderr=true#6847
fix: honor -stderrthreshold when -logtostderr=true#6847pierluigilenoci wants to merge 1 commit intopingcap:mainfrom
Conversation
klog v2 defaults -logtostderr to true, which silently ignores -stderrthreshold — all severities are unconditionally sent to stderr. Bump klog to v2.140.0 and opt into the fixed behavior by setting legacy_stderr_threshold_behavior=false so that -stderrthreshold is respected. The default is set to INFO (preserving current behavior); users can now override it on the command line. Ref: kubernetes/klog#212, kubernetes/klog#432 Signed-off-by: Pierluigi Lenoci <pierluigi.lenoci@gmail.com> Signed-off-by: Pierluigi Lenoci <pierluigilenoci@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @pierluigilenoci. Thanks for your PR. I'm waiting for a pingcap member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
Welcome @pierluigilenoci! It looks like this is your first PR to pingcap/tidb-operator 🎉 |
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6847 +/- ##
=======================================
Coverage 36.35% 36.35%
=======================================
Files 392 392
Lines 27234 27234
=======================================
Hits 9902 9902
Misses 17332 17332
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
What
Bump klog to v2.140.0 and opt into the fixed behavior so that
-stderrthresholdis respected even when-logtostderr=true(the default).Why
klog v2 defaults
-logtostderrtotrue. When active, the-stderrthresholdflag is silently ignored — all log severities are unconditionally written to stderr. This makes it impossible for log-aggregation systems to filter by severity.This has been an open issue since 2020: kubernetes/klog#212
The fix was merged in klog v2.140.0 via kubernetes/klog#432 (authored by me) and introduces an opt-in flag
legacy_stderr_threshold_behavior. Setting it tofalseenables the corrected behavior where-stderrthresholdis honored.What changes
cmd/tidb-backup-manager/main.go, afterklog.InitFlags(), two flags are set:legacy_stderr_threshold_behavior=false— enables the fixstderrthreshold=INFO— preserves current behavior (all severities still go to stderr by default)Since these are set before flag parsing, users can now override
-stderrthreshold=WARNINGor-stderrthreshold=ERRORon the command line and it will actually work.References