Skip to content

Honor stderrthreshold when logtostderr is enabled#794

Merged
google-oss-prow[bot] merged 2 commits into
kubeflow:masterfrom
pierluigilenoci:fix/honor-stderrthreshold
Apr 14, 2026
Merged

Honor stderrthreshold when logtostderr is enabled#794
google-oss-prow[bot] merged 2 commits into
kubeflow:masterfrom
pierluigilenoci:fix/honor-stderrthreshold

Conversation

@pierluigilenoci
Copy link
Copy Markdown
Contributor

Summary

Opt into the new klog behavior so that -stderrthreshold is honored even when -logtostderr=true (the default). Set stderrthreshold=INFO to preserve backward compatibility.

Background

When -logtostderr=true, -stderrthreshold was ignored -- all logs went to stderr. Fixed in kubernetes/klog#432 (v2.140.0+), but projects must opt in.

Changes

  • Added flag.Set("legacy_stderr_threshold_behavior", "false") and flag.Set("stderrthreshold", "INFO") after klog.InitFlags() in cmd/mpi-operator/main.go
  • Bumped k8s.io/klog/v2 from v2.130.1 to v2.140.0

References

@pierluigilenoci
Copy link
Copy Markdown
Contributor Author

Hi @tenzen-y, @terrytangyuan, @alculquicondor -- would you be willing to review? Thank you!

@tenzen-y
Copy link
Copy Markdown
Member

tenzen-y commented Apr 3, 2026

Hi @tenzen-y, @terrytangyuan, @alculquicondor -- would you be willing to review? Thank you!

@pierluigilenoci Thank you for opening this PR, the changes look great!
But, we have to update Go version to 1.26 to address CI problem in a separate PR in advance.

mkdir -p /home/runner/work/mpi-operator/mpi-operator/go/src/github.com/kubeflow/mpi-operator/bin
go: downloading sigs.k8s.io/controller-runtime/tools/setup-envtest v0.0.0-20260402120904-17460276e0da
go: downloading sigs.k8s.io/controller-runtime v0.23.3
go: sigs.k8s.io/controller-runtime/tools/setup-envtest@latest: sigs.k8s.io/controller-runtime/tools/setup-envtest@v0.0.0-20260402120904-17460276e0da requires go >= 1.26.0 (running go 1.25.0; GOTOOLCHAIN=local)
make: *** [Makefile:160: bin/envtest] Error 1
Error: Process completed with exit code 2.

Could you open a PR to update the Go version separately in advance?
Thank you.

Comment thread cmd/mpi-operator/main.go Outdated
Comment on lines +44 to +46
// Opt into fixed stderrthreshold behavior (kubernetes/klog#212).
_ = flag.Set("legacy_stderr_threshold_behavior", "false")
_ = flag.Set("stderrthreshold", "INFO")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@pierluigilenoci
Copy link
Copy Markdown
Contributor Author

Hi @tenzen-y — thank you for the review and the positive feedback! Two items to address: (1) Move flags to options.go — will move the flag.CommandLine.Set calls into cmd/mpi-operator/app/options/options.go as requested. (2) Go 1.26 update — understood, the Validate CI failure is because controller-runtime/tools/setup-envtest now requires Go >= 1.26.0. I will open a separate PR to bump the Go version first, then rebase this one on top. Will update shortly. Thank you!

@pierluigilenoci
Copy link
Copy Markdown
Contributor Author

Hi @tenzen-y — thank you for the review feedback! I saw the note about updating the Go version.

Just to confirm: the Validate CI failure (setup-envtest requires go >= 1.26.0, running go 1.25.0) is a repo-wide issue — it also fails on PR #795 with the same error. This is not caused by changes in this PR.

I'm happy to address the Go version update as part of this PR or in a separate one — whichever you prefer. Could you let me know how you'd like to proceed? Thank you!

@tenzen-y
Copy link
Copy Markdown
Member

Hi @tenzen-y — thank you for the review feedback! I saw the note about updating the Go version.

Just to confirm: the Validate CI failure (setup-envtest requires go >= 1.26.0, running go 1.25.0) is a repo-wide issue — it also fails on PR #795 with the same error. This is not caused by changes in this PR.

I'm happy to address the Go version update as part of this PR or in a separate one — whichever you prefer. Could you let me know how you'd like to proceed? Thank you!

Thank you for opening that! I left a small comment for the Go version PR, could you address that? After that we can move PRs move forward.

@tenzen-y
Copy link
Copy Markdown
Member

@pierluigilenoci, could you rebase this PR on top of the master branch? Because we merged your Go version updating PR to the master branch.

Opt into the fixed klog 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>
Move klog.InitFlags() and stderrthreshold flag settings from
cmd/mpi-operator/main.go to cmd/mpi-operator/app/options/options.go
as requested in code review.

Signed-off-by: Pierluigi Lenoci <pierluigi.lenoci@gmail.com>
@pierluigilenoci pierluigilenoci force-pushed the fix/honor-stderrthreshold branch from 86808ea to 5dc78bc Compare April 13, 2026 23:33
@pierluigilenoci
Copy link
Copy Markdown
Contributor Author

Hi @tenzen-y, I've rebased onto master (now includes the Go 1.26.0 bump from #796) and moved the flag initialization to cmd/mpi-operator/app/options/options.go as requested. Thank you!

Copy link
Copy Markdown
Member

@tenzen-y tenzen-y left a comment

Choose a reason for hiding this comment

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

Awesome, thank you!
/lgtm
/approve

@google-oss-prow
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: tenzen-y

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@google-oss-prow google-oss-prow Bot merged commit 78f2365 into kubeflow:master Apr 14, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants