Uh oh!
There was an error while loading. Please reload this page.
fix(doctor): surface container restart history, not just crash-loop-now (#1028 item 4) - #231
Conversation
…ow (#1028) checkRestartHistory warns when any init/regular container RestartCount >= 3 — the current-state check missed pods that already crashed. Additive. Refs #1008.
aptracebloc
left a comment
There was a problem hiding this comment.
Approving. Clean, low-risk additive check — warn-only, correctly-motivated, and well-tested. Two non-blocking notes below.
Nice separation from podCrashLooping: RestartCount is the wrong signal for crash-loop-now (recovered/completed pods carry high counts) but the right one for the history signal this check is about, and it's honest ("may be flapping even if it's up now") and capped at ⚠ so it never overrides the crash-loop-now failure. Threshold 3 is well-reasoned, and it matches the doctor Result pattern (init+app scan, list-error → Warn, sorted output).
Non-blocking notes
- No pod-phase / recency filter. It counts
RestartCounton all pods present, including Succeeded/Failed (completed jobs) — so a long-finished job that retried ≥3 times keeps this check ⚠ until that pod is GC'd, which could be persistent noise where completed pods linger. ContrastpodCrashLooping, which deliberately excludes terminal phases. Intended per the "history" framing, but worth a thought (filter to non-terminal pods, or accept the tradeoff). - "No overlap" is really "independent, not gating." A real crash-looping pod has
RestartCount ≥ 3, so it'll trip both this ⚠ andcheckPods' ✖ — acceptable (different facets;Worst()stays ✖), but the test's RestartCount-0 crash-loop doesn't reflect actual crash-loopers, so the "no overlap" claim is a touch optimistic in practice.
Neither blocks — approving as-is.
— drafted with Claude (Opus 4.8), sent by @aptracebloc
Uh oh!
There was an error while loading. Please reload this page.
#241 was stacked on #237 (resources SHOW), which squash-merged to develop; develop also gained the #244 status-aware home screen + #231 top-level doctor. Resolved: - internal/cli/resources.go, resources_test.go → #241's (the BUILT `set`). develop's copy is #237's SHOW + the deferred `resources set` stub, and #241 is exactly the PR that replaces that stub with the real command. Only #237 ever touched these files on develop, so no SHOW change is lost. - internal/cli/root.go → develop's (new home screen + top-level doctor); #241 adds nothing to root.go (`resources` is wired via resources.go).
What
cluster doctorreported crash-loops from current pod state only, so it missed pods that had already restarted (crashed) earlier — backend#1028 (Item 4 of the prod-audit lows).Fix
checkRestartHistory— scans both init and regular container statuses across the tracebloc pods and warns when any container'sRestartCount >= 3, naming each offender + akubectl logs --previousremedy. Matches the existing doctor check/Result pattern.Test
TestCheckRestartHistory: no-restarts / below-threshold → OK; at/above-threshold → Warn; init-container restarts → Warn; crash-loop-now pod (RestartCount 0) → OK here (proves no overlap).go build/test/vet/gofmtclean.Refs backend#1008. (Items 1/2/3 — digest pin, OOM-orphan sweep, correlation id — tracked separately.)
🤖 Generated with Claude Code
Note
Low Risk
Read-only diagnostic addition with warn-only severity; existing pod crash-loop detection is unchanged.
Overview
tracebloc cluster doctornow includes a Restart history check so operators see containers that have flapped even when they are healthy right now.The existing Pod health check only treats active
CrashLoopBackOffas failure, so pods that restarted several times and recovered (or jobs that retried before succeeding) could still look fine. The new check lists pods in the namespace, scans init and app container statuses, and emits ⚠ when anyRestartCountis ≥ 3 (threshold chosen to avoid noise from 1–2 routine restarts). It names each pod/container and suggestskubectl logs … --previous; it does not replace or duplicate the crash-loop-now failure path.Tests cover threshold edge cases, init-container restarts, and that crash-looping pods stay this check’s responsibility vs Pod health; the integration test expects 9 checks instead of 8.
Reviewed by Cursor Bugbot for commit 7dc0eb3. Bugbot is set up for automated code reviews on this repo. Configure here.