Skip to content

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

Closed
pierluigilenoci wants to merge 1 commit intoredhat-developer:mainfrom
pierluigilenoci:cs/fix-klog-stderrthreshold
Closed

Migrate from klog v1 to klog/v2 and honor stderrthreshold#7364
pierluigilenoci wants to merge 1 commit intoredhat-developer:mainfrom
pierluigilenoci:cs/fix-klog-stderrthreshold

Conversation

@pierluigilenoci
Copy link
Copy Markdown

What type of PR is this?

Bug fix / Dependency update

What does this PR do?

Migrate from deprecated k8s.io/klog (v1) to k8s.io/klog/v2 and opt into
the fixed stderrthreshold behavior introduced in klog/v2 v2.140.0.

Without this fix, the -stderrthreshold flag is silently ignored
when -logtostderr=true (klog's default), making it impossible to
filter log output by severity.

Changes

  • Replace all "k8s.io/klog" imports with "k8s.io/klog/v2" across 80+ source files
  • Update k8s.io/klog/v2 from v2.100.1 to v2.140.0 in go.mod
  • Fix klog.V(4) boolean check to klog.V(4).Enabled() for klog/v2 API compatibility
  • After each klog.InitFlags(nil), set legacy_stderr_threshold_behavior=false and stderrthreshold=INFO
  • Run go mod tidy and go mod vendor

How should this be tested?

  • go build ./... passes
  • go vet ./... passes
  • Existing tests should continue to pass

References

Replace deprecated k8s.io/klog with k8s.io/klog/v2 and opt into
the fixed stderrthreshold behavior introduced in klog/v2 v2.140.0.

Without this fix, the -stderrthreshold flag is silently ignored
when -logtostderr=true (klog's default), making it impossible to
filter log output by severity.

Also fix klog.V() boolean check to use klog.V().Enabled() for
klog/v2 API compatibility.

See: kubernetes/klog#432
Signed-off-by: Pierluigi Lenoci <pierluigi.lenoci@gmail.com>
@netlify
Copy link
Copy Markdown

netlify bot commented Mar 27, 2026

Deploy Preview for odo-docusaurus-preview canceled.

Name Link
🔨 Latest commit 19a53c6
🔍 Latest deploy log https://app.netlify.com/projects/odo-docusaurus-preview/deploys/69c5ca06012b780008bedf33

@openshift-ci openshift-ci bot requested review from kadel and rm3l March 27, 2026 00:06
@pierluigilenoci
Copy link
Copy Markdown
Author

Hi @feloy, @rm3l — this PR migrates from deprecated klog v1 to klog/v2 and opts into the fixed stderrthreshold behavior. Would you be willing to review? Thank you!

@openshift-ci
Copy link
Copy Markdown

openshift-ci bot commented Mar 27, 2026

Hi @pierluigilenoci. Thanks for your PR.

I'm waiting for a redhat-developer member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@openshift-ci openshift-ci bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. Required by Prow. label Mar 27, 2026
@sonarqubecloud
Copy link
Copy Markdown

@pierluigilenoci
Copy link
Copy Markdown
Author

Closing in favor of #7363 which was created first. Sorry for the duplicate.

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

Labels

needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. Required by Prow.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant