Skip to content

fix: honor stderrthreshold when logtostderr is enabled#22785

Open
pierluigilenoci wants to merge 1 commit intokubernetes:masterfrom
pierluigilenoci:fix/honor-stderrthreshold
Open

fix: honor stderrthreshold when logtostderr is enabled#22785
pierluigilenoci wants to merge 1 commit intokubernetes:masterfrom
pierluigilenoci:fix/honor-stderrthreshold

Conversation

@pierluigilenoci
Copy link
Copy Markdown

@pierluigilenoci pierluigilenoci commented Mar 26, 2026

What this PR does

Bumps klog from v2.130.1 to v2.140.0 and opts into the fixed stderrthreshold behavior so that the -stderrthreshold flag is actually honored even when -logtostderr=true.

Problem

klog v2 defaults -logtostderr to true. When active, -stderrthreshold is silently ignored — all log levels (INFO through FATAL) are unconditionally sent 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

Fix

  1. Bump klog from v2.130.1 to v2.140.0 to get the -legacy_stderr_threshold_behavior flag
  2. Set the flag to false to enable the fix
  3. Set stderrthreshold=INFO to preserve current default behavior (all logs still go to stderr), while allowing users to override it at runtime with e.g. -stderrthreshold=WARNING

The two flag.Set() calls are placed after klog.InitFlags(nil) and before the test-specific flag overrides.

References

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: pierluigilenoci
Once this PR has been reviewed and has the lgtm label, please assign prezha for approval. For more information see the Code Review Process.

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

@k8s-ci-robot k8s-ci-robot requested review from medyagh and nirs March 26, 2026 23:16
@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Mar 26, 2026
@pierluigilenoci
Copy link
Copy Markdown
Author

Hi @medyagh, @spowelljr, @tstromberg — would you be willing to review? Thank you!

@minikube-bot
Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@pierluigilenoci
Copy link
Copy Markdown
Author

/retest

@pierluigilenoci
Copy link
Copy Markdown
Author

/ok-to-test

@k8s-ci-robot k8s-ci-robot added the ok-to-test Indicates a non-member PR verified by an org member that is safe to test. label Mar 28, 2026
@pierluigilenoci
Copy link
Copy Markdown
Author

/retest

3 similar comments
@pierluigilenoci
Copy link
Copy Markdown
Author

/retest

@pierluigilenoci
Copy link
Copy Markdown
Author

/retest

@pierluigilenoci
Copy link
Copy Markdown
Author

/retest

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Mar 31, 2026
@pierluigilenoci
Copy link
Copy Markdown
Author

Friendly follow-up — this PR has been waiting for review for about 15 days. The CI failures appear to be infrastructure flakes (pod scheduling timeouts, job failures unrelated to the code change) — the actual build check (pull-minikube-build) passes.

@medyagh @prezha @ComradeProgrammer — would you be able to take a look when you get a chance? It's a small fix to honor the stderrthreshold klog flag. Happy to address any feedback or retest as needed. Thank you!

@pierluigilenoci
Copy link
Copy Markdown
Author

/retest

@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 13, 2026
@pierluigilenoci
Copy link
Copy Markdown
Author

/retest

1 similar comment
@pierluigilenoci
Copy link
Copy Markdown
Author

/retest

@pierluigilenoci pierluigilenoci force-pushed the fix/honor-stderrthreshold branch from 0fbfd0f to 839f2d3 Compare April 20, 2026 18:29
@pierluigilenoci
Copy link
Copy Markdown
Author

/retest

klog v2 defaults -logtostderr to true. When active, -stderrthreshold is
silently ignored — all log levels are unconditionally sent to stderr.
This makes it impossible for log-aggregation systems to filter by severity.

Bump klog from v2.130.1 to v2.140.0, which introduces the
-legacy_stderr_threshold_behavior flag. Setting it to false enables the
fix. We also set -stderrthreshold=INFO to preserve the current default
behavior while allowing users to 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>
@pierluigilenoci pierluigilenoci force-pushed the fix/honor-stderrthreshold branch from 839f2d3 to fa1f665 Compare April 21, 2026 17:26
@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Apr 21, 2026
@pierluigilenoci pierluigilenoci changed the title Honor stderrthreshold when logtostderr is enabled fix: honor stderrthreshold when logtostderr is enabled Apr 21, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

@pierluigilenoci: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-minikube-none-containerd-linux-x86 fa1f665 link false /test pull-minikube-none-containerd-linux-x86
pull-minikube-none-docker-linux-x86 fa1f665 link true /test pull-minikube-none-docker-linux-x86
pull-minikube-docker-containerd-linux-x86 fa1f665 link true /test pull-minikube-docker-containerd-linux-x86
pull-minikube-docker-containerd-linux-arm fa1f665 link false /test pull-minikube-docker-containerd-linux-arm
pull-minikube-docker-docker-linux-x86 fa1f665 link true /test pull-minikube-docker-docker-linux-x86
pull-minikube-docker-docker-linux-arm fa1f665 link true /test pull-minikube-docker-docker-linux-arm
pull-minikube-kvm-crio-linux-x86 fa1f665 link false /test pull-minikube-kvm-crio-linux-x86
pull-minikube-kvm-docker-linux-x86 fa1f665 link true /test pull-minikube-kvm-docker-linux-x86
pull-minikube-kvm-containerd-linux-x86 fa1f665 link true /test pull-minikube-kvm-containerd-linux-x86
pull-minikube-docker-crio-linux-x86 fa1f665 link false /test pull-minikube-docker-crio-linux-x86

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants