Skip to content

fix: honor -stderrthreshold when -logtostderr=true (#6847)#6869

Merged
ti-chi-bot[bot] merged 2 commits intopingcap:release-2.1from
ti-chi-bot:cherry-pick-6847-to-release-2.1
Apr 29, 2026
Merged

fix: honor -stderrthreshold when -logtostderr=true (#6847)#6869
ti-chi-bot[bot] merged 2 commits intopingcap:release-2.1from
ti-chi-bot:cherry-pick-6847-to-release-2.1

Conversation

@ti-chi-bot
Copy link
Copy Markdown
Member

This is an automated cherry-pick of #6847

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>
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>
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 37.44%. Comparing base (2881ae6) to head (fbd4212).

Additional details and impacted files
@@             Coverage Diff              @@
##           release-2.1    #6869   +/-   ##
============================================
  Coverage        37.44%   37.44%           
============================================
  Files              392      392           
  Lines            22432    22432           
============================================
  Hits              8399     8399           
  Misses           14033    14033           
Flag Coverage Δ
unittest 37.44% <ø> (ø)

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.

@liubog2008
Copy link
Copy Markdown
Member

/lgtm

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

ti-chi-bot Bot commented Apr 29, 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 29, 2026
@ti-chi-bot
Copy link
Copy Markdown
Contributor

ti-chi-bot Bot commented Apr 29, 2026

[LGTM Timeline notifier]

Timeline:

  • 2026-04-29 00:54:26.758643592 +0000 UTC m=+2732071.964003649: ☑️ agreed by liubog2008.

@ti-chi-bot ti-chi-bot Bot merged commit 72613a0 into pingcap:release-2.1 Apr 29, 2026
10 checks passed
@ti-chi-bot ti-chi-bot Bot deleted the cherry-pick-6847-to-release-2.1 branch April 29, 2026 05:08
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