Repository navigation
fix(cli): top, dashboard and cluster watch refuse an --interval under one second - #393
Merged
Merged
Conversation
… 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Item 1.6 of the CLI performance and stability plan (finding F28). Independent of the other Wave 1 PRs.
Why
kates top,kates dashboardandkates cluster watchtake--intervalas 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 0sent 20,347 requests in 3 s, a hot loop against a real Kates API.kates test watchalready guards this, by keeping its default poll interval unless the flag is positive.Changes
cli/cmd/top.go: newcheckInterval, which refuses an interval under 1 second with--interval must be at least 1 second, got N.top,dashboardandcluster watchcall it before their first request.Tests
Added
TestRefreshCommandsRefuseIntervalUnderOneSecond, a table over the three commands:--interval0 and -1 against a client that cannot call out, and returns the refusal.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.shandscripts/check-cli-compat.sh: OK.cli/**triggers (Build & Test): this PR touches nothing underkates/../mvnw teston main'skates/tree ran 1,254 tests with 0 failures and 0 errors, once for all of Wave 1.Skipped locally:
govulncheck, asgo.modis unchanged.CI only:
./mvnw verifywith the*ITtests, the Kind and Docker jobs, CodeQL and Trivy.