Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/cmd/k9s.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ func newK9sCommand() *cobra.Command {

// Mimic k9s/main.go:init()
klog.InitFlags(nil)
// Opt into the new klog behavior so that -stderrthreshold is honored even
// when -logtostderr=true (the default).
// Ref: kubernetes/klog#212, kubernetes/klog#432
flag.Set("legacy_stderr_threshold_behavior", "false") //nolint:errcheck
flag.Set("stderrthreshold", "INFO") //nolint:errcheck
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.

Isn't this duplicative of line 40/45

if err := flag.Set("stderrthreshold", "fatal"); err != nil {
	return err
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

You're right on both counts, and I appreciate you taking the time to walk through this carefully.

  1. legacy_stderr_threshold_behavior: this flag only changes klog's behavior when logtostderr=true. Since this project explicitly sets logtostderr=false (line 42), the stderrthreshold is already honored by klog regardless — making the opt-in a no-op here.

  2. stderrthreshold=INFO: yes, this is immediately overwritten by stderrthreshold=fatal on line 45. Dead code.

I misread the existing code and assumed logtostderr was left at the klog default (true). The project's explicit logtostderr=false makes both additions unnecessary.

I'll close this PR. Sorry for the noise, and thanks for the thorough review.

if err := flag.Set("logtostderr", "false"); err != nil {
return err
}
Expand Down