Skip to content

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

Merged
ti-chi-bot[bot] merged 2 commits intopingcap:mainfrom
pierluigilenoci:fix/honor-stderrthreshold
Apr 28, 2026
Merged

fix: honor -stderrthreshold when -logtostderr=true#6847
ti-chi-bot[bot] merged 2 commits intopingcap:mainfrom
pierluigilenoci:fix/honor-stderrthreshold

Conversation

@pierluigilenoci
Copy link
Copy Markdown
Contributor

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

pingcap-cla-assistant Bot commented Apr 22, 2026

CLA assistant check
All committers have signed the CLA.

@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-commenter commented Apr 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 37.44%. Comparing base (818d6d3) to head (56f034e).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6847      +/-   ##
==========================================
+ Coverage   36.35%   37.44%   +1.08%     
==========================================
  Files         392      392              
  Lines       27234    22434    -4800     
==========================================
- Hits         9902     8400    -1502     
+ Misses      17332    14034    -3298     
Flag Coverage Δ
unittest 37.44% <ø> (+1.08%) ⬆️

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.

The project disables errcheck but enables gosec, whose G104 rule also
catches unhandled error returns. Replace //nolint:errcheck directives
with explicit error handling.

Signed-off-by: Pierluigi Lenoci <pierluigilenoci@gmail.com>
@liubog2008
Copy link
Copy Markdown
Member

/ok-to-test

@liubog2008
Copy link
Copy Markdown
Member

/lgtm
/cherry-pick release-2.1

@ti-chi-bot
Copy link
Copy Markdown
Member

@liubog2008: once the present PR merges, I will cherry-pick it on top of release-2.1 in the new PR and assign it to you.

Details

In response to this:

/lgtm
/cherry-pick release-2.1

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 ti-community-infra/tichi repository.

@ti-chi-bot ti-chi-bot Bot added the lgtm label Apr 28, 2026
@ti-chi-bot
Copy link
Copy Markdown
Contributor

ti-chi-bot Bot commented Apr 28, 2026

[LGTM Timeline notifier]

Timeline:

  • 2026-04-28 15:16:37.226971791 +0000 UTC m=+2697402.432331848: ☑️ agreed by liubog2008.

@ti-chi-bot
Copy link
Copy Markdown
Contributor

ti-chi-bot Bot commented Apr 28, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: liubog2008

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

The pull request process is described 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 ti-chi-bot Bot added the approved label Apr 28, 2026
@ti-chi-bot ti-chi-bot Bot merged commit 8e8144f into pingcap:main Apr 28, 2026
9 of 10 checks passed
@ti-chi-bot
Copy link
Copy Markdown
Member

@liubog2008: new pull request created to branch release-2.1: #6869.

Details

In response to this:

/lgtm
/cherry-pick release-2.1

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 ti-community-infra/tichi repository.

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.

4 participants