Honor stderrthreshold when logtostderr is enabled#8667
Honor stderrthreshold when logtostderr is enabled#8667pierluigilenoci wants to merge 1 commit intocert-manager:masterfrom
Conversation
cert-manager already calls klog.InitFlags() and registers stderrthreshold as a (deprecated) flag. However, because logtostderr defaults to true and klog's legacy behavior silently ignores stderrthreshold in that case, the flag is a no-op — users who pass --stderrthreshold=ERROR get no effect. Opt into the fixed klog behavior (available since v2.140.0, which cert-manager already uses) so that stderrthreshold is honored regardless of logtostderr. This does not add any new user-facing flags; it makes the existing deprecated flag work correctly until it is eventually removed. References: - kubernetes/klog#212 - kubernetes/klog#432 Signed-off-by: Pierluigi Lenoci <pierluigi.lenoci@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @pierluigilenoci. Thanks for your PR. I'm waiting for a cert-manager member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
|
Hi @pierluigilenoci this seems to be a duplicate of #8653. |
|
Note: This replaces #8653, which I closed prematurely after @hjoshi123's feedback about KEP-2845. The branch was deleted along with the closure, so the original PR cannot be reopened — hence this new one. After further analysis, I'm convinced the fix is correct and valuable. The key points are in the PR description above, but in short: cert-manager already calls |
|
@pierluigilenoci, please stop spamming. If you want to bring arguments to the table on why we should accept the PR, please reopen #8653. /close |
|
@erikgb: Closed this PR. DetailsIn response to this:
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. |
|
Hi @erikgb, unfortunately I cannot reopen this PR — I accidentally deleted the branch. I apologize for the inconvenience. If the fix is still desired, I'd be happy to open a fresh PR. Thanks! |
Hi @pierluigilenoci, I don't understand why you cannot reopen #8653. If you deleted the branch just push a copy of the branch using the same name as in the PR. |
Description
When
logtostderristrue(the default), klog historically ignoredstderrthreshold, silently dropping the filtering that should have beenapplied. This was fixed in klog v2.140.0 by introducing
legacy_stderr_threshold_behavior. Setting it tofalsemakes kloghonour
stderrthresholdregardless oflogtostderr.This PR adds two lines after
klog.InitFlags()inAddFlags:Why this replaces #8653
I closed #8653 after @hjoshi123 raised a concern about KEP-2845 deprecating klog-specific flags. On closer review, I believe that concern does not apply here, for the reasons below.
cert-manager already uses these flags internally
pkg/logs/logs.goalready:klog.InitFlags(&allFlags)(line 72) — initializing the full klog flag setstderrthresholdas a deprecated-but-functional flag (lines 76-82) — users can pass--stderrthreshold=ERRORtodaygo.mod) — the exact version that ships thelegacy_stderr_threshold_behaviorfixKEP-2845 deprecates flags for future removal — it does not break them
KEP-2845 marks these flags as deprecated so they can be removed in a future release. cert-manager follows this by hiding the flags and adding a deprecation warning. But deprecation ≠ broken: a flag that is registered, accepted by the binary, and documented as deprecated should still function correctly until it is actually removed.
Today, a user who passes
--stderrthreshold=ERRORto any cert-manager binary gets zero effect — the flag is silently a no-op becauselogtostderr=true(the default) overrides it. This is confusing and arguably worse than the KEP-2845 concern: the flag exists, is accepted without error, but does nothing.This change adds no new user-facing flags
The fix is purely internal configuration: it tells klog to use its corrected behavior so that the already-registered
stderrthresholdflag works as expected. No new flags are added, no deprecated flags are un-deprecated, and the deprecation warning remains intact.Summary
stderrthresholdregistered?stderrthresholdfunctional?References
/cc @erikgb @ThatsMrTalbot @hjoshi123