Skip to content

fix(relay): run the same-cap headroom gate in the modes the job actually receives - #24343

Merged
Jinwoo-H merged 1 commit into
mainfrom
fix/relay-same-cap-headroom-gate
Oct 1, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
fix/relay-same-cap-headroom-gate

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​107 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​107
Prod 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​7 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​3

ELI5

Before the production relay workflow takes a server out of service, it is supposed to check that the other servers have room for the users that will be moved. That check never ran, because it waited for a mode name the step never receives. This PR makes it run.

What Changed

The production rollout workflow is split in two. The outer workflow takes a dispatch mode (verify, canary-apply, batch-apply, rollback). Before calling the per-cell job, it turns both apply modes into the single job mode apply. The headroom check added in #24259 only ran when the job's mode was canary-apply or batch-apply, and the job never sees those names. So the check was skipped on every real roll; run 36839965464 shows it skipped while the cell drained.

The step now runs on env.ROLLBACK_RESUME != 'true'. Each dispatch mode now behaves like this:

Dispatch mode Headroom check Why
verify runs The check only reads status from the director and the cell, which verify already does. It gives the real headroom answer before anyone dispatches an apply.
canary-apply, batch-apply runs These drain the cell. This is the case #24259 meant to protect.
rollback before its restart runs It isolates and drains the cell just like apply. Hosts with nowhere to go strand it the same way.
rollback resuming after its restart skipped It skips the drain step, so it moves no hosts.

The check counts hosts connected to the cell right now. Verify now fails when there is not enough room. In a multi-cell verify, that failure stops the cells after it from being verified, the same as any other verify failure. A cell that a failed canary already drained has about zero. So a rollback of that cell passes the check and is not blocked from recovering.

A new test, cloud/dev/scripts/relay-same-cap-job-mode-conditions.test.mjs, reads both workflow files and checks three things:

  • The modes the outer workflow can pass match the modes the job validates.
  • No job step compares inputs.mode against a value the job cannot receive.
  • For every mode and resume combination, if the drain step runs then the headroom step runs. The test evaluates both steps' real if: expressions. It also checks that verify runs the headroom step.

With the old condition, the second and third checks fail.

The docs in cloud/docs/relay-workflows.md now list the modes that run the check.

Why

The fix is to tie the check to the drain, not to dispatch names. Two alternatives were rejected:

  • Matching on apply: that would fix this bug but still let rollback drain without a check.
  • Passing the original dispatch mode down to the job: that adds a second mode input that every other step would have to reconcile.

The test checks behavior, not one exact string, so the next renamed mode or new drain path fails CI instead of failing silently in production.

Linked Issue

Follow-up to #24259.

Visual Proof

N/A. This changes CI workflow conditions only, with no UI.

Testing

  • Automated tests added/updated, or explained why not below
  • The new test passes on this branch. With the old condition put back, it fails with job compares against canary-apply and drain without headroom check: apply/false.
  • Every node --test file in the cloud package passes except relay-load-control-peer.test.mjs. That file fails locally because the lane install is missing tweetnacl, which is unrelated to this change.
  • No workflow was dispatched.

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Production relay CI only. This has no effect on the desktop app, SSH, mobile, or any platform.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…lly receives

The parent workflow collapses canary-apply and batch-apply into the job mode
apply, so the headroom step's canary-apply/batch-apply condition never held and
the gate was skipped on every real roll. Run it wherever the drain runs (apply,
rollback before its restart) and in read-only verify; skip only a resumed
rollback, which drains nothing. A new workflow-shape test fails on any job
step comparing against a mode the parent cannot pass, and on a drain that can
run without the headroom check.

Claude-Session: ced32ebb-7155-4413-adad-1eccd14c2010
@pullfrog

pullfrog Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor
  • Checkout PR and read full diff
  • Read PR summary snapshot
  • Triage and investigate surrounding code
  • Dispatch specialists if unresolved questions
  • Draft and submit review
  • Update PR summary snapshot

Pullfrog  | View workflow run | via Pullfrog | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@greptile-apps

greptile-apps Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[High risk] Changes deployment workflow gate conditions for production relay jobs.

The PR appears safe to merge; no actionable issue was identified.

Summary

The PR makes the same-cap headroom check run for the job modes that can drain a cell, adds a workflow-condition regression test, and documents when the check runs.

  • Apply and non-resuming rollback check headroom before draining; verify checks without draining.
  • A rollback resuming after restart skips the check because it skips the drain.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Per-cell job] --> B{Rollback resuming after restart?}
  B -- Yes --> C[Skip headroom and drain]
  B -- No --> D[Check headroom]
  D --> E{Job mode}
  E -- Verify --> F[Finish read-only verification]
  E -- Apply or rollback --> G[Isolate and drain selected cell]
Loading

Reviews (1) · Last reviewed commit: "fix(relay): run the same-cap headroom ga..."

@Jinwoo-H
Jinwoo-H merged commit 9ed7b39 into main Oct 1, 2026
27 of 28 checks passed
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