Skip to content

fix(controller): align the stall-dump threshold with doctor's liveness limit - #393

Merged
kyle-sexton merged 1 commit into
mainfrom
fix/watchdog-stall-threshold
Sep 23, 2026
Merged

kyle-sexton merged 1 commit into
mainfrom
fix/watchdog-stall-threshold

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

No related issue: follow-up to #383, found during the v0.1.26 rollout on melo-desk-001.

Summary

The stall watchdog from #383 dumped goroutines after 12 × reconcileInterval (60s at the default 5s). On melo-desk-001 it fired 60s after the v0.1.26 controller started, while the reconcile loop was legitimately blocked in ensureImage pulling the new worker image. host doctor's liveness check (#382) already allows 5 minutes for exactly these heartbeat-free Step phases, so the two thresholds disagreed.

Fix

  • internal/controller now owns one rule, ReconcileLivenessLimit(interval) = max(5m, 6 × interval), with the constants ReconcileLivenessFloor and ReconcileLivenessIntervals. It saturates instead of overflowing.
  • WatchHeartbeat builds its watch through newHeartbeatWatch, which uses that rule, so a dump now coincides with doctor's FAIL.
  • host doctor calls the same function and drops its local copy. Doctor output is unchanged.

Verification

  • TestHeartbeatWatchWritesOneDumpPerStallEpisode asserts that the watch threshold equals ReconcileLivenessLimit(interval), the function doctor calls. It checks there is no dump at limit−1s, one dump per stall episode, and that the watch re-arms after a fresh heartbeat.
  • TestReconcileLivenessLimitScalesTheIntervalAboveAFloor: 5s gives 5m, 2m gives 12m, and MaxInt64/2 saturates.
  • TestDoctorReconcileLiveness passes unchanged.
  • All of these exit 0:
    • go build ./...
    • go test ./...
    • go test -race ./... (Linux, WSL)
    • golangci-lint run ./... (v2.13.1)
    • CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -trimpath ./cmd/...

Related

🤖 Generated with Claude Code

…s limit

WatchHeartbeat dumped goroutines after 12 reconcile intervals (60s at the
default 5s), so a worker image pull after an upgrade produced a dump while
host doctor still reported the loop live. Both now use
controller.ReconcileLivenessLimit: max(5m, 6 x interval), saturating on
overflow, so a stall dump coincides with doctor's liveness FAIL.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-23T18:55:28.826621Z 8e49e9f PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@kyle-sexton
kyle-sexton merged commit 551f34f into main Sep 23, 2026
2 checks passed
@kyle-sexton
kyle-sexton deleted the fix/watchdog-stall-threshold branch September 23, 2026 18:55
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