dnsmasq-nanny: honor -stderrthreshold flag via klog v2.140.0#763
dnsmasq-nanny: honor -stderrthreshold flag via klog v2.140.0#763pierluigilenoci wants to merge 1 commit into
Conversation
|
Skipping CI for Draft Pull Request. |
|
[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 |
|
Hi — friendly follow-up. Would you be able to review this PR when you get a chance? Thank you! |
DamianSawicki
left a comment
There was a problem hiding this comment.
This repository is planned to be archived (#759 (comment), kubernetes/kubernetes#137556). Consider migrating away from dnsmasq-nanny or arguing against archiving.
| // when -logtostderr=true (the default). | ||
| // Ref: kubernetes/klog#212, kubernetes/klog#432 | ||
| flag.Set("legacy_stderr_threshold_behavior", "false") //nolint:errcheck | ||
| flag.Set("stderrthreshold", "INFO") //nolint:errcheck |
There was a problem hiding this comment.
It seems cmd/dnsmasq-nanny/main.go has not used stderrthreshold before, and it's only proposed in the present PR. I suppose the behavior without these two new flags was to log everything.
- In order not to change this existing behavior,
stderrthresholdshould probably default toWARNING. - In order to allow the user to adjust filtering to their preferences,
stderrthresholdshould be configurable and not hardcoded.
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>
c1584a8 to
325010a
Compare
|
Thanks for the review @DamianSawicki, and for the context on the archival plans (#759, kubernetes/kubernetes#137556) — much appreciated. I've addressed the technical feedback:
Re: archival — happy to defer to your judgement on whether this PR is still worth landing given the deprecation timeline. If you'd prefer to close it, no objection on my side. Otherwise, I'm available if any further changes are needed. |
|
Thanks for the review and context, @DamianSawicki. Given that the repo is heading toward archival (#759, kubernetes/kubernetes#137556) and dnsmasq-nanny usage should be migrated away from, it makes no sense to land this fix here. Closing this out. Best of luck with the migration work! |
Summary
klog v2 defaults
-logtostderr=true, which silently overrides-stderrthreshold. This makes it impossible to filter log output by severity level using the-stderrthresholdflag in dnsmasq-nanny.klog v2.140.0 (kubernetes/klog#432) introduced the
legacy_stderr_threshold_behaviorfeature flag that fixes this long-standing behavior (upstream issue: kubernetes/klog#212).Changes
k8s.io/klog/v2from v2.130.1 to v2.140.0cmd/dnsmasq-nanny/main.go: Afterklog.InitFlags(nil), setlegacy_stderr_threshold_behavior=falseandstderrthreshold=INFOso that-stderrthresholdis 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/...succeedsgo build ./cmd/kube-dns/...succeedsgo build ./cmd/sidecar/...succeedsnode-cachehas a pre-existing build failure on non-Linux due to iptables dependency — unrelated to this change)