Skip to content

fix: honor --stderrthreshold flag when --logtostderr is enabled#6786

Merged
ti-chi-bot[bot] merged 2 commits intopingcap:release-1.xfrom
pierluigilenoci:fix/honor-stderrthreshold
Apr 1, 2026
Merged

fix: honor --stderrthreshold flag when --logtostderr is enabled#6786
ti-chi-bot[bot] merged 2 commits intopingcap:release-1.xfrom
pierluigilenoci:fix/honor-stderrthreshold

Conversation

@pierluigilenoci
Copy link
Copy Markdown

What this PR does

The backup manager calls pflag.Set("logtostderr", "true") which enables klog's logtostderr mode. However, due to klog's legacy behavior, the --stderrthreshold flag is silently ignored when logtostderr is true.

This PR:

  1. Adds proper error handling for the existing bare pflag.Set("logtostderr", "true") call
  2. Opts into the fixed behavior introduced in klog v2.130.0 by setting:
    • legacy_stderr_threshold_behavior=false — disables the legacy override
    • stderrthreshold=INFO — preserves the current default behavior
  3. Bumps klog/v2 from v2.110.1 to v2.140.0

After this change, the --stderrthreshold flag works as expected in the backup manager.

Why

See upstream fix: kubernetes/klog#432

@ti-chi-bot
Copy link
Copy Markdown
Contributor

ti-chi-bot bot commented Mar 28, 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.

@github-actions github-actions bot added the v2 for operator v2 label Mar 28, 2026
@ti-chi-bot
Copy link
Copy Markdown
Contributor

ti-chi-bot bot commented Mar 28, 2026

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

@pierluigilenoci
Copy link
Copy Markdown
Author

Hi @cofyc, @csuzhangxc — this small fix adds proper error handling for the pflag.Set call in the backup manager and ensures the --stderrthreshold flag works correctly when --logtostderr is enabled. Would you be willing to review? Thank you!

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

@ti-chi-bot ti-chi-bot bot added the size/S label Mar 28, 2026
@liubog2008
Copy link
Copy Markdown
Member

liubog2008 commented Mar 29, 2026

@pierluigilenoci Hi, thanks for your contribution. Could you resolve the conflicts? Notice the base should be release-1.x

@liubog2008 liubog2008 changed the base branch from main to release-1.x March 29, 2026 06:52
When logtostderr is enabled in the backup manager, klog's legacy behavior
ignores the stderrthreshold flag. This opts into the fixed behavior
introduced in klog v2.130.0 by setting legacy_stderr_threshold_behavior=false.

Also adds proper error handling for the existing bare pflag.Set() call.

See: kubernetes/klog#432
Signed-off-by: Pierluigi Lenoci <pierluigi.lenoci@gmail.com>
@pierluigilenoci pierluigilenoci force-pushed the fix/honor-stderrthreshold branch from e7325a3 to 9673285 Compare March 29, 2026 15:20
@pierluigilenoci
Copy link
Copy Markdown
Author

@liubog2008 Thanks for the review! I've rebased onto release-1.x and resolved the conflicts. Ready for review.

@pierluigilenoci
Copy link
Copy Markdown
Author

Hi @liubog2008, thanks for pointing that out! I've already rebased the branch onto release-1.x and resolved the go.mod/go.sum conflicts (bumped klog to v2.140.0). The PR should be clean now — could you take another look when you have a chance? Thank you!

@liubog2008
Copy link
Copy Markdown
Member

/ok-to-test

@liubog2008
Copy link
Copy Markdown
Member

@pierluigilenoci Fix CI issues. Thanks

@pierluigilenoci
Copy link
Copy Markdown
Author

/retest

Update k8s.io/klog/v2 from v2.110.1 to v2.140.0 and
github.com/go-logr/logr from v1.3.0 to v1.4.1 in pkg/apis
and pkg/client submodules to match the main module versions.

This fixes the check-modules CI verification failure.

Signed-off-by: Pierluigi Lenoci <pierluigi.lenoci@gmail.com>
@ti-chi-bot ti-chi-bot bot added size/M and removed size/S labels Mar 30, 2026
@pierluigilenoci
Copy link
Copy Markdown
Author

Pushed a fix to align klog/v2 and go-logr/logr versions in the pkg/apis and pkg/client submodules to match the main module. The verify check should now pass.

@pierluigilenoci
Copy link
Copy Markdown
Author

/retest

@liubog2008
Copy link
Copy Markdown
Member

/test pull-e2e-kind-across-kubernetes

@liubog2008
Copy link
Copy Markdown
Member

/lgtm

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

ti-chi-bot bot commented Apr 1, 2026

[LGTM Timeline notifier]

Timeline:

  • 2026-04-01 01:27:29.345723894 +0000 UTC m=+314854.551083951: ☑️ agreed by liubog2008.

@ti-chi-bot
Copy link
Copy Markdown
Contributor

ti-chi-bot bot commented Apr 1, 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 1, 2026
@liubog2008
Copy link
Copy Markdown
Member

/cherry-pick release-1.6

@ti-chi-bot
Copy link
Copy Markdown
Member

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

Details

In response to this:

/cherry-pick release-1.6

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 merged commit ec1360d into pingcap:release-1.x Apr 1, 2026
14 of 15 checks passed
@ti-chi-bot
Copy link
Copy Markdown
Member

@liubog2008: new pull request created to branch release-1.6: #6789.

Details

In response to this:

/cherry-pick release-1.6

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.

3 participants