Skip to content

fix: honor -stderrthreshold when -logtostderr is set#664

Open
pierluigilenoci wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
pierluigilenoci:fix/honor-stderrthreshold
Open

fix: honor -stderrthreshold when -logtostderr is set#664
pierluigilenoci wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
pierluigilenoci:fix/honor-stderrthreshold

Conversation

@pierluigilenoci
Copy link
Copy Markdown

Summary

klog v2 defaults -logtostderr=true, which causes the -stderrthreshold flag to be silently ignored (kubernetes/klog#212).

klog v2.140.0 introduced the legacy_stderr_threshold_behavior flag that restores correct behavior (kubernetes/klog#432).

Changes

  • Bump k8s.io/klog/v2 from v2.130.1 to v2.140.0 in both the root module and the kubectl-utils submodule.
  • After every klog.InitFlags() call (cmd/main.go and kubectl-utils/cmd/kubectl-expect/main.go), set legacy_stderr_threshold_behavior=false and stderrthreshold=INFO so that -stderrthreshold is honored regardless of -logtostderr.

Why it matters

Without this fix, any user or operator trying to control log verbosity via -stderrthreshold gets no effect because -logtostderr=true short-circuits the threshold check. This is a long-standing klog quirk that affects all consumers.

Testing

  • go build ./cmd/... — passes
  • go build ./kubectl-utils/cmd/kubectl-expect/... — passes
  • No behavioral change when -stderrthreshold is not explicitly set; existing log routing is preserved.

klog v2 defaults `-logtostderr=true`, which causes the
`-stderrthreshold` flag to be silently ignored (kubernetes/klog#212).

klog v2.140.0 introduced the `legacy_stderr_threshold_behavior` flag
that restores correct behavior (kubernetes/klog#432).

This commit:
- Bumps k8s.io/klog/v2 from v2.130.1 to v2.140.0 in both the root
  module and the kubectl-utils submodule.
- After every `klog.InitFlags()` call (cmd/main.go and
  kubectl-utils/cmd/kubectl-expect/main.go), sets
  `legacy_stderr_threshold_behavior=false` and `stderrthreshold=INFO`
  so that `-stderrthreshold` is honored regardless of `-logtostderr`.

Signed-off-by: Pierluigi Lenoci <pierluigi.lenoci@gmail.com>
Signed-off-by: Pierluigi Lenoci <pierluigilenoci@gmail.com>
@pierluigilenoci
Copy link
Copy Markdown
Author

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

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.

1 participant