Skip to content

fix: honor -stderrthreshold when -logtostderr=true#6847

Open
pierluigilenoci wants to merge 1 commit intopingcap:mainfrom
pierluigilenoci:fix/honor-stderrthreshold
Open

fix: honor -stderrthreshold when -logtostderr=true#6847
pierluigilenoci wants to merge 1 commit intopingcap:mainfrom
pierluigilenoci:fix/honor-stderrthreshold

Conversation

@pierluigilenoci
Copy link
Copy Markdown

What

Bump klog to v2.140.0 and opt into the fixed behavior so that -stderrthreshold is respected even when -logtostderr=true (the default).

Why

klog v2 defaults -logtostderr to true. When active, the -stderrthreshold flag 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 to false enables the corrected behavior where -stderrthreshold is honored.

What changes

  1. klog bumped from v2.130.1 to v2.140.0
  2. In cmd/tidb-backup-manager/main.go, after klog.InitFlags(), two flags are set:
    • legacy_stderr_threshold_behavior=false — enables the fix
    • stderrthreshold=INFO — preserves current behavior (all severities still go to stderr by default)

Since these are set before flag parsing, users can now override -stderrthreshold=WARNING or -stderrthreshold=ERROR on the command line and it will actually work.

References

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>
@ti-chi-bot ti-chi-bot Bot requested a review from shonge April 22, 2026 14:25
@ti-chi-bot
Copy link
Copy Markdown
Contributor

ti-chi-bot Bot commented Apr 22, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign mikechengwei for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot
Copy link
Copy Markdown
Contributor

ti-chi-bot Bot commented Apr 22, 2026

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions 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.

@ti-chi-bot
Copy link
Copy Markdown
Contributor

ti-chi-bot Bot commented Apr 22, 2026

Welcome @pierluigilenoci! It looks like this is your first PR to pingcap/tidb-operator 🎉

@pingcap-cla-assistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions github-actions Bot added the v2 for operator v2 label Apr 22, 2026
@ti-chi-bot ti-chi-bot Bot added the size/S label Apr 22, 2026
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 36.35%. Comparing base (818d6d3) to head (ff64e83).

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           
Flag Coverage Δ
unittest 36.35% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants