Migrate from klog v1 to klog/v2 and honor stderrthreshold#309
Open
pierluigilenoci wants to merge 1 commit intoAliyunContainerService:masterfrom
Open
Conversation
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>
Author
|
cc @ringtail @KeyOfSpectator for review |
yshngg
approved these changes
Mar 30, 2026
Contributor
yshngg
left a comment
There was a problem hiding this comment.
Thanks for contributing, LGTM!
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! |
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/klogimports withk8s.io/klog/v2across all 33 non-vendor Go source filesgo.modto depend onk8s.io/klog/v2 v2.140.0and rungo mod tidy+go mod vendorstderrthreshold=INFOandlegacy_stderr_threshold_behavior=falseafterklog.InitFlags()ineventer.goso that log messages are properly written to stderrMotivation
k8s.io/klogv1 is deprecated and unmaintained. Migrating tok8s.io/klog/v2brings bug fixes, better performance, and alignment with the broader Kubernetes ecosystem.Additionally, klog's default
stderrthresholdbehavior 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 successfullygo test ./...