fix: honor -stderrthreshold when -logtostderr=true#1080
fix: honor -stderrthreshold when -logtostderr=true#1080pierluigilenoci wants to merge 1 commit intokubernetes:masterfrom
Conversation
klog v2 defaults -logtostderr to true, which silently ignores -stderrthreshold — all severities are unconditionally sent to stderr. Opt into the fixed behavior introduced in klog v2.140.0 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>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: pierluigilenoci 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 |
|
This issue is currently awaiting triage. If the repository mantainers determine this is a relevant issue, they will accept it by applying the The 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. |
|
/ok-to-test |
What
Opt into the fixed klog behavior so that
-stderrthresholdis respected even when-logtostderr=true(the default).Why
klog v2 defaults
-logtostderrtotrue. When active, the-stderrthresholdflag 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 tofalseenables the corrected behavior where-stderrthresholdis honored.What changes
After
klog.InitFlags(), two flags are set in all 3 entry points:legacy_stderr_threshold_behavior=false— enables the fixstderrthreshold=INFO— preserves current behavior (all severities still go to stderr by default)Since these are set before flag parsing, users can now override
-stderrthreshold=WARNINGor-stderrthreshold=ERRORon the command line and it will actually work.Files modified
cmd/auth-provider-gcp/main.gocmd/gke-gcloud-auth-plugin/cred.gometis/cmd/main.goReferences