Skip to content

feat: node cordon/drain (#36)#39

Merged
CMGS merged 1 commit into
mainfrom
feat/drain
Jul 13, 2026
Merged

feat: node cordon/drain (#36)#39
CMGS merged 1 commit into
mainfrom
feat/drain

Conversation

@CMGS

@CMGS CMGS commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Implements #36: an operator verb to take a node out of service cleanly.

Semantics (as designed in the issue):

  • POST /v1/drain (root only): new claims/forks/branches answer 429 node draining through the existing ErrQuota gate — on a cluster the warm-peer redirect fires first, and gossip stops naming the node within a tick as its warm counts hit zero. Unclaimed warm VMs are destroyed via the existing trim path; live claims run to their leases. Answers the fresh info payload ("draining": true); poll claimed to zero.
  • DELETE /v1/drain: uncordons and kicks an immediate refill.
  • Not persisted, never touches pools.json — maintenance intent is not pool configuration; a restarted node serves again (documented).
  • In-flight refills and golden builds complete but are discarded/idle while draining (refillOne keep/chain guards, refillOnce gate).
  • GET /v1/info and the SDK NodeInfo gain draining; /metrics gains sandboxd_draining; SDK gains Client.Drain/Client.Uncordon (root helpers, per-node by nature).

Hot-path cost: zero — one bool inside the existing quotaErr check, already on the admission path.

Evidence: make go-test green (all modules, -race); dual-GOOS lint + fmt 0 issues; new tests cover drain-refuses-claims (warm + provision), warm-trim destruction, refill-suppression while draining, uncordon-refills-to-target, endpoint auth/round-trip (server), and POST/DELETE wire shape (SDK).

Closes #36.

…ve claims

Drain is a runtime override, deliberately not persisted and never written
to pools.json: maintenance intent is not pool configuration. Admission
reuses the ErrQuota gate, so a cluster redirects to warm peers before
answering 429.
@CMGS CMGS merged commit d813ea8 into main Jul 13, 2026
1 check passed
@CMGS CMGS deleted the feat/drain branch July 13, 2026 07:06
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.

ops: node cordon/drain — refuse new claims, drain warm pools, leave live claims to their leases

1 participant