Skip to content

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

Open
pierluigilenoci wants to merge 2 commits intopingcap:release-1.xfrom
pierluigilenoci:fix/honor-stderrthreshold
Open

fix: honor --stderrthreshold flag when --logtostderr is enabled#6786
pierluigilenoci wants to merge 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
@ti-chi-bot
Copy link
Copy Markdown
Contributor

ti-chi-bot bot commented Mar 29, 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 dragonly 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

@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

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