Skip to content

fix(cli): top, dashboard and cluster watch refuse an --interval under one second - #393

Merged
bmscomp merged 1 commit into
mainfrom
fix/cli-refuse-zero-interval
Oct 18, 2026
Merged

bmscomp merged 1 commit into
mainfrom
fix/cli-refuse-zero-interval

Conversation

@bmscomp

@bmscomp bmscomp commented Oct 18, 2026

Copy link
Copy Markdown
Owner

Item 1.6 of the CLI performance and stability plan (finding F28). Independent of the other Wave 1 PRs.

Why

kates top, kates dashboard and kates cluster watch take --interval as any integer and sleep that many seconds between refreshes (on main, 6f4cf61: cli/cmd/top.go:28,114,120, dashboard.go:259,265, cluster_watch.go:55,127,133). At 0 or below they never sleep. Against a counting stub, kates top --interval 0 sent 20,347 requests in 3 s, a hot loop against a real Kates API. kates test watch already guards this, by keeping its default poll interval unless the flag is positive.

Changes

  • cli/cmd/top.go: new checkInterval, which refuses an interval under 1 second with --interval must be at least 1 second, got N.
  • top, dashboard and cluster watch call it before their first request.

Tests

Added TestRefreshCommandsRefuseIntervalUnderOneSecond, a table over the three commands:

  • Each runs with --interval 0 and -1 against a client that cannot call out, and returns the refusal.
  • A regression would refresh forever, so each run gets 5 s before the test fails.
  • checkInterval(1) is accepted.

Run locally, passing:

  • cd cli && go test ./..., go test -race ./cmd, go vet ./....
  • golangci-lint run --new-from-rev=origin/main ./...: 0 issues.
  • scripts/check-cli-style.sh and scripts/check-cli-compat.sh: OK.
  • The backend suite, which cli/** triggers (Build & Test): this PR touches nothing under kates/. ./mvnw test on main's kates/ tree ran 1,254 tests with 0 failures and 0 errors, once for all of Wave 1.

Skipped locally: govulncheck, as go.mod is unchanged.

CI only: ./mvnw verify with the *IT tests, the Kind and Docker jobs, CodeQL and Trivy.

… one second

`kates top`, `kates dashboard` and `kates cluster watch` slept --interval
seconds between refreshes and took any integer. At 0 or below they never
slept: top sent 20,347 requests in 3 s to a stub API, a hot loop against a
real one. `kates test watch` already falls back to its default for that.

The three commands now refuse an interval under 1 second before their first
request, through a shared checkInterval. TestRefreshCommandsRefuseIntervalUnderOneSecond
runs each with 0 and -1 against a client that cannot call out.
@bmscomp
bmscomp merged commit 1ca4ea6 into main Oct 18, 2026
55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant