fix: honor klog -stderrthreshold even when -logtostderr is true#7662
fix: honor klog -stderrthreshold even when -logtostderr is true#7662pierluigilenoci wants to merge 1 commit intoGoogleCloudPlatform:masterfrom
Conversation
|
@pierluigilenoci: The label(s) 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/test-infra repository. |
|
[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 |
klog v2 defaults -logtostderr to true, which silently causes -stderrthreshold to be ignored. klog v2.140.0 introduced the legacy_stderr_threshold_behavior flag that restores proper stderrthreshold semantics. Bump k8s.io/klog/v2 from v2.130.1 to v2.140.0 across all modules and set legacy_stderr_threshold_behavior=false + stderrthreshold=INFO immediately after every klog.InitFlags call. Note: dev/tools/controllerbuilder/cmd/resourcerunner/main.go is left untouched because it imports klog v1, which does not have this flag. Ref: kubernetes/klog#212, kubernetes/klog#432 Signed-off-by: Pierluigi Lenoci <pierluigilenoci@gmail.com>
1dac2ba to
ac07fb3
Compare
What type of PR is this?
/kind bug
What this PR does / why we need it:
klog v2 defaults
-logtostderrtotrue, which silently causes-stderrthresholdto be ignored. This means operators cannot tune theseverity threshold for stderr output — every log line is already sent to
stderr regardless.
klog v2.140.0 introduced the
legacy_stderr_threshold_behaviorflag(kubernetes/klog#432) to fix this. Setting it to
falseimmediatelyafter
klog.InitFlagsrestores proper-stderrthresholdsemantics.This PR:
k8s.io/klog/v2from v2.130.1 → v2.140.0 in everygo.mod(root,dev/tools/controllerbuilder,experiments/composite,experiments/tools/licensescan,mockgcp) and the root replacedirective.
klog.InitFlagscall site (10 files) to opt intothe new behavior:
flag.Set("legacy_stderr_threshold_behavior", "false")/flag.Set("stderrthreshold", "INFO")for sites using the defaultflag.CommandLinefs.Set(...)for sites using a customflag.FlagSetdev/tools/controllerbuilder/cmd/resourcerunner/main.gountouched — it imports klog v1, which doesn't have this flag.
Which issue(s) this PR fixes:
Ref: kubernetes/klog#212, kubernetes/klog#432
Does this PR introduce a user-facing change?