Skip to content

upgrade-drain: retry a coordinator call that answers Unavailable - #1781

Merged
nikhilunni merged 3 commits into
mainfrom
fix/drain-job-retries-coordinator
Nov 10, 2026
Merged

nikhilunni merged 3 commits into
mainfrom
fix/drain-job-retries-coordinator

Conversation

@nikhilunni

@nikhilunni nikhilunni commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A host-fleet helm upgrade failed at its pre-upgrade drain hook: the hook's first call, list_hosts, got Unavailable (connection refused). The coordinator Deployment had reported its rollout complete seconds earlier and both new pods were listening, so the Service still routed to a stopping pod. A rerun of the deploy passed.

The two fleet reads of the drain's Coordinator client (engram-upgrade-drain), list_hosts and list_sessions, now retry: on Unavailable they try again every 2 s, up to 30 attempts (about a minute). Any other status fails at once. The budget counts attempts, so the code reads no clock (ADR 0098). A failure of one of these reads ends the hook, so they are the calls that must wait for the coordinator. Both hooks use this client: upgrade-drain (coordinator and host-operator images) and upgrade-roll.

The actions (cordon, the checkpoint read, snapshot, resume, evict) get one try, as before. The coordinator also answers Unavailable when its own call to a host fails, and the drain already sends a failed action again on its next pass; a wait inside the call would hold the other actions of that pass for a minute per call on a session whose host is dead.

Test plan

  • Unit tests on a scripted call: two refusals then success (3 calls, Ok); PermissionDenied fails after 1 call; retries stop at the attempt limit; an action gets one try.
  • cargo clippy -p engram-upgrade-drain -p engram-host-operator --all-targets -D warnings
  • cargo nextest run -p engram-upgrade-drain: 8/8
  • CI Gate

🤖 Generated with Claude Code

https://claude.ai/code/session_017XkqDqWbQdPXdy94AdFV5e

nikhilunni and others added 3 commits November 9, 2026 08:42
The host-fleet pre-upgrade drain failed on its first call: list_hosts got
`Unavailable` (connection refused). The coordinator rollout had finished
seconds before, so the Service still routed to a stopping pod. The drain
loop retries its actions, but a failed list_hosts or list_sessions at the
top of a pass ended the hook.

Every call of the drain's Coordinator client now goes through one retry:
on `Unavailable` it tries again every 2 s, up to 30 attempts (about a
minute). Any other status fails at once. The retry counts attempts, so it
reads no clock (ADR 0098). Both hooks (`upgrade-drain` in the coordinator
and host-operator images, and `upgrade-roll`) use this client.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017XkqDqWbQdPXdy94AdFV5e
The coordinator answers `Unavailable` for two different things: it is
not reachable, and its own call to a host failed. The retry treated both
the same, so an evict, snapshot or resume of a session on a dead host
waited a minute per call inside its pass, and held the other actions of
that pass, where it failed in seconds before. The drain already sends a
failed action again on its next pass.

`list_hosts` and `list_sessions` keep the retry: their failure ends the
hook. Cordon, the checkpoint read, snapshot, resume and evict get one
try.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HNhpmz4QPYaVCE7tFna54D
@nikhilunni
nikhilunni merged commit dc5e8ca into main Nov 10, 2026
52 of 54 checks passed
@nikhilunni
nikhilunni deleted the fix/drain-job-retries-coordinator branch November 10, 2026 15:26
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