Migrate from klog v1 to klog/v2 and honor stderrthreshold#2046
Open
pierluigilenoci wants to merge 1 commit intovmware-tanzu:mainfrom
Open
Migrate from klog v1 to klog/v2 and honor stderrthreshold#2046pierluigilenoci wants to merge 1 commit intovmware-tanzu:mainfrom
pierluigilenoci wants to merge 1 commit intovmware-tanzu:mainfrom
Conversation
Migrate from k8s.io/klog (v1) to k8s.io/klog/v2 v2.140.0. Opt into the fixed stderrthreshold behavior by setting legacy_stderr_threshold_behavior=false after klog.InitFlags(). Ref: kubernetes/klog#212, kubernetes/klog#432 Signed-off-by: Pierluigi Lenoci <pierluigi.lenoci@gmail.com>
Author
|
cc @johnSchnake @zubron @timothysc for review |
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.
Summary
k8s.io/klog(v1) tok8s.io/klog/v2v2.140.0stderrthresholdbehavior by settinglegacy_stderr_threshold_behavior=falseandstderrthreshold=INFOafterklog.InitFlags()Why
k8s.io/klogv1 is unmaintained and has a long-standing bug where thestderrthresholdflag defaults toERROR, causingINFOandWARNINGlog messages to be silently dropped from stderr. Theklog/v2module provides thelegacy_stderr_threshold_behaviorflag that, when set tofalse, restores the expected behavior of routing all log levels to stderr.Changes
cmd/sonobuoy/app/root.go: Updated import fromk8s.io/klogtok8s.io/klog/v2. Addedflag.Set("legacy_stderr_threshold_behavior", "false")andflag.Set("stderrthreshold", "INFO")right afterklog.InitFlags(nil)inside theinitKlogfunction.go.mod/go.sum: Replaced directk8s.io/klog v1.0.0dependency withk8s.io/klog/v2 v2.140.0.References
Test plan
go build ./...compiles without errors