Skip to content

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

Open
pierluigilenoci wants to merge 1 commit intoAliyunContainerService:masterfrom
pierluigilenoci:fix/migrate-klog-v2-honor-stderrthreshold
Open

Migrate from klog v1 to klog/v2 and honor stderrthreshold#309
pierluigilenoci wants to merge 1 commit intoAliyunContainerService:masterfrom
pierluigilenoci:fix/migrate-klog-v2-honor-stderrthreshold

Conversation

@pierluigilenoci
Copy link
Copy Markdown

Summary

  • Replace all k8s.io/klog imports with k8s.io/klog/v2 across all 33 non-vendor Go source files
  • Update go.mod to depend on k8s.io/klog/v2 v2.140.0 and run go mod tidy + go mod vendor
  • Configure stderrthreshold=INFO and legacy_stderr_threshold_behavior=false after klog.InitFlags() in eventer.go so that log messages are properly written to stderr

Motivation

k8s.io/klog v1 is deprecated and unmaintained. Migrating to k8s.io/klog/v2 brings bug fixes, better performance, and alignment with the broader Kubernetes ecosystem.

Additionally, klog's default stderrthreshold behavior silently drops INFO/WARNING messages from stderr unless explicitly configured. This patch ensures all log levels are emitted to stderr as expected.

Ref: kubernetes/klog#212, kubernetes/klog#432

Test plan

  • go build ./... compiles successfully
  • Run existing unit tests: go test ./...
  • Verify klog output appears on stderr at all verbosity levels

Replace all imports of k8s.io/klog with k8s.io/klog/v2 across all
non-vendor Go source files (33 files), update go.mod dependencies,
and configure stderrthreshold to ensure log messages are properly
written to stderr.

Ref: kubernetes/klog#212, kubernetes/klog#432
Signed-off-by: Pierluigi Lenoci <pierluigi.lenoci@gmail.com>
@pierluigilenoci
Copy link
Copy Markdown
Author

cc @ringtail @KeyOfSpectator for review

Copy link
Copy Markdown
Contributor

@yshngg yshngg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing, LGTM!

@pierluigilenoci
Copy link
Copy Markdown
Author

Friendly follow-up — this PR migrates klog v1 to v2 and has been ready for review for a couple of weeks. @ringtail @KeyOfSpectator would you be able to take a look? There are no CI checks configured on this repo, but the change is straightforward and follows the standard klog migration pattern. Thank you!

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.

2 participants