fix: opt into fixed klog stderrthreshold behavior#13872
Open
pierluigilenoci wants to merge 1 commit intok3s-io:mainfrom
Open
fix: opt into fixed klog stderrthreshold behavior#13872pierluigilenoci wants to merge 1 commit intok3s-io:mainfrom
pierluigilenoci wants to merge 1 commit intok3s-io:mainfrom
Conversation
Set legacy_stderr_threshold_behavior=false and stderrthreshold=INFO in the klog flag loop alongside the existing verbosity setting. This addresses the klog bug (kubernetes/klog#432) where WARNING+ messages are duplicated on stderr when logtostderr=true, because the legacy stderrthreshold mechanism operates independently. The flags are set inside the existing loop (not just once) to match the current pattern: Kubernetes components re-initialize klog on start, resetting flags to defaults. The loop re-applies the desired values every second for the first 2 minutes. stderrthreshold=INFO preserves current behavior (all levels visible on stderr) while using the corrected code path. Signed-off-by: Pierluigi Lenoci <pierluigi.lenoci@gmail.com>
2 tasks
Author
|
Hi @brandond — this PR applies the klog stderrthreshold fix to |
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.
Problem
klog's legacy
stderrthresholdbehavior (kubernetes/klog#432) causes WARNING+ messages to be duplicated on stderr whenlogtostderr=true, because the legacy stderrthreshold mechanism operates independently of the logtostderr flag.Solution
Set
legacy_stderr_threshold_behavior=falseandstderrthreshold=INFOin the existing klog flag loop inpkg/executor/embed/embed.go, alongside the current verbosity (v) flag setting.legacy_stderr_threshold_behavior=false: Opts into the corrected behavior wherestderrthresholdis properly respectedstderrthreshold=INFO: Preserves the current observable behavior (all log levels visible on stderr) while using the corrected code pathBoth flags are set inside the loop (not just once after
klog.InitFlags) to match the existing pattern: Kubernetes components re-initialize klog on start, resetting flags to defaults. The loop re-applies desired values every second for the first 2 minutes.Context
This was originally submitted to rancher/rke2 (#10046), where @brandond correctly pointed out that the actual klog initialization for the process happens here in K3s, not in rke2's
pkg/logging/logging.go(which is only used for stripping legacy klog args from kubelet arguments).cc @brandond — does this look like the right approach?