fix: honor -stderrthreshold when -logtostderr is set#4903
Closed
pierluigilenoci wants to merge 1 commit intocilium:mainfrom
Closed
fix: honor -stderrthreshold when -logtostderr is set#4903pierluigilenoci wants to merge 1 commit intocilium:mainfrom
pierluigilenoci wants to merge 1 commit intocilium:mainfrom
Conversation
klog v2 defaults -logtostderr to true, which silently causes -stderrthreshold to be ignored. klog v2.140.0 introduced the legacy_stderr_threshold_behavior flag that restores the correct interaction between the two flags (see kubernetes/klog#432). This commit sets legacy_stderr_threshold_behavior=false after klog.InitFlags in pkg/logger/klog_bridge.go and sets stderrthreshold=INFO so the default behavior is preserved but users can now override it on the command line. Tetragon is already on klog v2.140.0 so no dependency bump is needed. Ref: kubernetes/klog#212 Signed-off-by: Pierluigi Lenoci <pierluigi.lenoci@gmail.com> Signed-off-by: Pierluigi Lenoci <pierluigilenoci@gmail.com>
Contributor
|
Hi! |
Author
|
Apologies — I missed that #4805 had already been submitted and closed. I mistakenly believed I hadn't opened a PR for this repository yet. Closing this as a duplicate. Sorry for the noise. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does
klog v2 defaults
-logtostderrtotrue, which silently causes-stderrthresholdto be ignored — all log messages of every severity are unconditionally written to stderr. There is no way for users to filter which severity levels reach stderr.This has been an open issue since 2020: kubernetes/klog#212.
klog v2.140.0 (kubernetes/klog#432) introduces a
legacy_stderr_threshold_behaviorflag that fixes this. This PR setslegacy_stderr_threshold_behavior=falseafterklog.InitFlagsinpkg/logger/klog_bridge.goand setsstderrthreshold=INFOso the default behavior is preserved but users can now override it on the command line (e.g.-stderrthreshold=WARNING).Tetragon is already on klog v2.140.0, so no dependency bump is needed.
Why it matters
While Tetragon's custom logging setup already routes klog output by severity via
SetOutputBySeverity, this change ensures the klog-internal stderrthreshold mechanism works correctly as a defense-in-depth measure. In production clusters, log aggregation systems (Fluentd, Fluent Bit, Loki, Datadog, etc.) benefit from proper severity filtering at the klog level.Changed files
pkg/logger/klog_bridge.golegacy_stderr_threshold_behavior=false+stderrthreshold=INFOafterklog.InitFlags