Skip to content

dnsmasq-nanny: honor -stderrthreshold flag via klog v2.140.0#763

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

dnsmasq-nanny: honor -stderrthreshold flag via klog v2.140.0#763
pierluigilenoci wants to merge 1 commit intokubernetes:masterfrom
pierluigilenoci:fix/honor-stderrthreshold

Conversation

@pierluigilenoci
Copy link
Copy Markdown
Member

Summary

klog v2 defaults -logtostderr=true, which silently overrides -stderrthreshold. This makes it impossible to filter log output by severity level using the -stderrthreshold flag in dnsmasq-nanny.

klog v2.140.0 (kubernetes/klog#432) introduced the legacy_stderr_threshold_behavior feature flag that fixes this long-standing behavior (upstream issue: kubernetes/klog#212).

Changes

  • Bump k8s.io/klog/v2 from v2.130.1 to v2.140.0
  • cmd/dnsmasq-nanny/main.go: After klog.InitFlags(nil), set legacy_stderr_threshold_behavior=false and stderrthreshold=INFO so that -stderrthreshold is honored even when -logtostderr=true (the default)

Why

Without this fix, passing -stderrthreshold=WARNING (or any other severity) to dnsmasq-nanny has no effect because klog's legacy behavior copies all log output to stderr regardless of the threshold. The new klog flag restores the expected semantics: only messages at or above the configured severity threshold are written to stderr.

Testing

  • go build ./cmd/dnsmasq-nanny/... succeeds
  • go build ./cmd/kube-dns/... succeeds
  • go build ./cmd/sidecar/... succeeds
  • (node-cache has a pre-existing build failure on non-Linux due to iptables dependency — unrelated to this change)

klog v2 defaults -logtostderr=true, which silently overrides
-stderrthreshold. This makes it impossible to filter log output by
severity level using the -stderrthreshold flag.

klog v2.140.0 (kubernetes/klog#432) introduced the
legacy_stderr_threshold_behavior feature flag that fixes this behavior
(upstream issue: kubernetes/klog#212).

Changes:
- Bump k8s.io/klog/v2 from v2.130.1 to v2.140.0
- After klog.InitFlags(nil), set legacy_stderr_threshold_behavior=false
  and stderrthreshold=INFO so that -stderrthreshold is honored even
  when -logtostderr=true

Signed-off-by: Pierluigi Lenoci <pierluigi.lenoci@gmail.com>
Signed-off-by: Pierluigi Lenoci <pierluigilenoci@gmail.com>
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 24, 2026
@k8s-ci-robot k8s-ci-robot requested a review from bowei April 24, 2026 08:00
@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 mrhohn 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 added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Apr 24, 2026
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. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants