Skip to content

Migrate from klog v1 to klog/v2 and honor stderrthreshold#2046

Open
pierluigilenoci wants to merge 1 commit intovmware-tanzu:mainfrom
pierluigilenoci:fix/migrate-klog-v2-honor-stderrthreshold
Open

Migrate from klog v1 to klog/v2 and honor stderrthreshold#2046
pierluigilenoci wants to merge 1 commit intovmware-tanzu:mainfrom
pierluigilenoci:fix/migrate-klog-v2-honor-stderrthreshold

Conversation

@pierluigilenoci
Copy link
Copy Markdown

Summary

  • Migrate the direct dependency 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 and stderrthreshold=INFO after klog.InitFlags()

Why

k8s.io/klog v1 is unmaintained and has a long-standing bug where the stderrthreshold flag defaults to ERROR, causing INFO and WARNING log messages to be silently dropped from stderr. The klog/v2 module provides the legacy_stderr_threshold_behavior flag that, when set to false, restores the expected behavior of routing all log levels to stderr.

Changes

  • cmd/sonobuoy/app/root.go: Updated import from k8s.io/klog to k8s.io/klog/v2. Added flag.Set("legacy_stderr_threshold_behavior", "false") and flag.Set("stderrthreshold", "INFO") right after klog.InitFlags(nil) inside the initKlog function.
  • go.mod / go.sum: Replaced direct k8s.io/klog v1.0.0 dependency with k8s.io/klog/v2 v2.140.0.

References

Test plan

  • go build ./... compiles without errors
  • Run existing test suite to verify no regressions

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>
@pierluigilenoci
Copy link
Copy Markdown
Author

cc @johnSchnake @zubron @timothysc for review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant