Skip to content

Commit

Permalink
cli: Add a --timeout flag to multicluster check (#11420)
Browse files Browse the repository at this point in the history
The `multicluster check` command misuses the `--wait` timeout as a limit
for communicating with the Kubernetes API server. The default --wait timeout
is very high, though.

This change adds a new `--timeout` flag so these behaviors can be controlled
independently.

Signed-off-by: Shashank <[email protected]>
Co-authored-by: Oliver Gould <[email protected]>
  • Loading branch information
moki1202 and olix0r authored Sep 29, 2023
1 parent 8840879 commit cbaff7b
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions multicluster/cmd/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,16 @@ const (
)

type checkOptions struct {
wait time.Duration
output string
wait time.Duration
output string
timeout time.Duration
}

func newCheckOptions() *checkOptions {
return &checkOptions{
wait: 300 * time.Second,
output: healthcheck.TableOutput,
wait: 300 * time.Second,
output: healthcheck.TableOutput,
timeout: 10 * time.Second,
}
}

Expand Down Expand Up @@ -107,6 +109,7 @@ non-zero exit code.`,
}
cmd.Flags().StringVarP(&options.output, "output", "o", options.output, "Output format. One of: table, json, short")
cmd.Flags().DurationVar(&options.wait, "wait", options.wait, "Maximum allowed time for all tests to pass")
cmd.Flags().DurationVar(&options.timeout, "timeout", options.timeout, "Timeout for calls to the Kubernetes API")
cmd.Flags().Bool("proxy", false, "")
cmd.Flags().MarkHidden("proxy")
cmd.Flags().StringP("namespace", "n", "", "")
Expand Down Expand Up @@ -151,7 +154,7 @@ func configureAndRunChecks(wout io.Writer, werr io.Writer, options *checkOptions
}

hc := newHealthChecker(linkerdHC)
category := multiclusterCategory(hc, options.wait)
category := multiclusterCategory(hc, options.timeout)
hc.AppendCategories(category)
success, warning := healthcheck.RunChecks(wout, werr, hc, options.output)
healthcheck.PrintChecksResult(wout, options.output, success, warning)
Expand Down

0 comments on commit cbaff7b

Please sign in to comment.