Skip to content

feat: 5s configurable metrics refresh + per-context auth resilience - #27

Merged
ErfanY merged 1 commit into
mainfrom
feat/metrics-refresh-interval
Jun 26, 2026
Merged

feat: 5s configurable metrics refresh + per-context auth resilience#27
ErfanY merged 1 commit into
mainfrom
feat/metrics-refresh-interval

Conversation

@ErfanY

@ErfanY ErfanY commented Jun 26, 2026

Copy link
Copy Markdown
Owner

Summary

Two robustness fixes that came out of real-cluster use.

Metrics refresh interval (configurable, default 5s)

Was hardcoded to 15s. Now runtime.metrics_interval_secs (default 5s). k9s polls everything every 2s; ours is bounded by metrics-server's ~15s sample resolution, so 5s is noticeably more live without hammering the API on large fleets — raise it for 20-cluster/10k-pod setups if needed.

Per-context auth resilience

A context that can't authenticate (expired SSO / exec-auth failure) no longer aborts startup — previously one bad context killed the whole app:

Error: failed to initialize Kubernetes provider
  Caused by: failed to create client for context … auth exec command … failed

Now: provider client warmup is best-effort (logs a warning), and replace_watch_plan records a per-context StateDelta::Error — shown as [XX] with the auth message — instead of failing the call. Other clusters stay fully usable; the broken context recovers on its own on a later watch tick once credentials refresh.

Testing

  • make validate green (110 tests + release build)
  • new test: a bad-auth context's watch plan records an error delta and returns Ok (doesn't fail)
  • the per-context auth path itself is best verified on a real cluster with an expired SSO token

🤖 Generated with Claude Code

Two robustness fixes from real-cluster use.

Metrics refresh: was hardcoded to 15s. Now `runtime.metrics_interval_secs`
(default 5s — k9s polls every 2s; ours is bounded by metrics-server's ~15s
sample resolution, so 5s is live without hammering the API on large fleets).
Threaded through run()/App::new.

Per-context auth resilience: a context that can't authenticate (expired SSO /
exec-auth failure) no longer aborts the whole app at startup. Provider client
warmup is best-effort (logs a warning, doesn't propagate), and replace_watch_plan
records a per-context StateDelta::Error — surfaced as [XX] with the auth
message — instead of failing the call. Other clusters stay fully usable, and the
broken context recovers on a later watch tick once credentials refresh.

Tests: bad-context watch plan records an error delta and returns Ok.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ErfanY
ErfanY merged commit 6e108c8 into main Jun 26, 2026
1 check passed
@ErfanY
ErfanY deleted the feat/metrics-refresh-interval branch June 26, 2026 00:24
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