Skip to content
Open
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
6 changes: 6 additions & 0 deletions pkg/azurediskplugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ var exit = func(code int) {

func main() {
flag.Parse()
if err := flag.Set("legacy_stderr_threshold_behavior", "false"); err != nil {
klog.Errorf("Failed to set legacy_stderr_threshold_behavior: %v", err)
}
if err := flag.Set("stderrthreshold", "INFO"); err != nil {
klog.Errorf("Failed to set stderrthreshold: %v", err)
Comment on lines 55 to +61
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

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

There are existing tests for this package, but none currently validate the new CLI behavior around honoring --stderrthreshold when logtostderr is enabled. Adding a unit test that sets os.Args with an explicit --stderrthreshold value and asserts it is not overridden would help prevent regressions in this flag-handling logic.

Suggested change
func main() {
flag.Parse()
if err := flag.Set("legacy_stderr_threshold_behavior", "false"); err != nil {
klog.Errorf("Failed to set legacy_stderr_threshold_behavior: %v", err)
}
if err := flag.Set("stderrthreshold", "INFO"); err != nil {
klog.Errorf("Failed to set stderrthreshold: %v", err)
func hasExplicitFlag(args []string, name string) bool {
prefix := "--" + name
for i := 0; i < len(args); i++ {
arg := args[i]
if arg == prefix {
return true
}
if strings.HasPrefix(arg, prefix+"=") {
return true
}
}
return false
}
func main() {
flag.Parse()
if err := flag.Set("legacy_stderr_threshold_behavior", "false"); err != nil {
klog.Errorf("Failed to set legacy_stderr_threshold_behavior: %v", err)
}
if !hasExplicitFlag(os.Args[1:], "stderrthreshold") {
if err := flag.Set("stderrthreshold", "INFO"); err != nil {
klog.Errorf("Failed to set stderrthreshold: %v", err)
}

Copilot uses AI. Check for mistakes.
}
Comment on lines 56 to +62
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

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

flag.Set is being called after flag.Parse(), which will override any user-provided --legacy_stderr_threshold_behavior / --stderrthreshold values from the command line. That contradicts the PR goal of letting users tune --stderrthreshold (e.g., to WARNING/ERROR). Consider setting these values before flag.Parse() so CLI args can still override them, or only applying the stderrthreshold=INFO fallback when that flag wasn't explicitly provided (and update the flag's default/usage value if you want --help / usage text to reflect the new default).

Suggested change
flag.Parse()
if err := flag.Set("legacy_stderr_threshold_behavior", "false"); err != nil {
klog.Errorf("Failed to set legacy_stderr_threshold_behavior: %v", err)
}
if err := flag.Set("stderrthreshold", "INFO"); err != nil {
klog.Errorf("Failed to set stderrthreshold: %v", err)
}
if err := flag.Set("legacy_stderr_threshold_behavior", "false"); err != nil {
klog.Errorf("Failed to set legacy_stderr_threshold_behavior: %v", err)
}
if err := flag.Set("stderrthreshold", "INFO"); err != nil {
klog.Errorf("Failed to set stderrthreshold: %v", err)
}
flag.Parse()

Copilot uses AI. Check for mistakes.
if *version {
info, err := azuredisk.GetVersionYAML(driverOptions.DriverName)
if err != nil {
Expand Down
Loading