Skip to content

Honor stderrthreshold when logtostderr is enabled#782

Merged
wencaiwulue merged 1 commit into
kubenetworks:masterfrom
pierluigilenoci:fix/honor-stderrthreshold
Jun 13, 2026
Merged

Honor stderrthreshold when logtostderr is enabled#782
wencaiwulue merged 1 commit into
kubenetworks:masterfrom
pierluigilenoci:fix/honor-stderrthreshold

Conversation

@pierluigilenoci

Copy link
Copy Markdown
Contributor

What

Bump k8s.io/klog/v2 to v2.140.0 and opt out of the legacy stderr threshold behavior so that -stderrthreshold is respected even when -logtostderr=true (the klog v2 default).

Why

klog v2 defaults -logtostderr to true, which silently ignores -stderrthreshold. All log levels are unconditionally sent to stderr, making severity-based filtering impossible for log aggregation systems.

This was reported in kubernetes/klog#212 and fixed upstream in kubernetes/klog#432.

How

  • Call klog.InitFlags(nil) in main() to register klog flags on the standard flag set
  • Set legacy_stderr_threshold_behavior=false to opt into the corrected behavior
  • Set stderrthreshold=INFO as default to preserve current behavior (all logs still go to stderr)
  • Users can now override via -stderrthreshold=WARNING or -stderrthreshold=ERROR

Bump k8s.io/klog/v2 to v2.140.0 and opt out of the legacy stderr
threshold behavior so that -stderrthreshold is respected even when
-logtostderr=true (the default).  Set stderrthreshold=INFO to preserve
current behavior; users can now override it on the command line.

Ref: kubernetes/klog#212, kubernetes/klog#432
Signed-off-by: Pierluigi Lenoci <pierluigilenoci@gmail.com>
@pierluigilenoci

Copy link
Copy Markdown
Contributor Author

Hi — friendly ping. Is this PR still on the radar for review? Happy to rebase or make changes if needed. Thanks!

@pierluigilenoci

Copy link
Copy Markdown
Contributor Author

Hi — friendly follow-up. The CI failures appear to be infrastructure-related (the image build can't push to ghcr.io from a fork PR, and integration tests depend on that image). The code changes themselves are minimal (klog v2 dependency update). Would you be able to review when you get a chance? Thank you!

@pierluigilenoci

Copy link
Copy Markdown
Contributor Author

Hi — friendly follow-up on this PR. The CI seems to be failing due to a permissions issue when the workflow tries to push to ghcr.io/kubenetworks/ from a fork (error: denied: installation not allowed to Write organization package). This is expected for fork-based PRs and cannot be fixed from my side.

Would it be possible to either:

  1. Configure the workflow to skip the image push step for PRs from forks, or
  2. Let me know if there's another way to satisfy the CI requirements?

Happy to make any code changes needed on my end. Thanks!

@wencaiwulue wencaiwulue merged commit 731738c into kubenetworks:master Jun 13, 2026
3 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants