Skip to content

feat(relay): slower same-cap drain paces (15 and 20 min) for every cell class - #26350

Merged
Jinwoo-H merged 2 commits into
mainfrom
relay-slow-drain-pace
Oct 7, 2026
Merged

Jinwoo-H merged 2 commits into
mainfrom
relay-slow-drain-pace

Conversation

@Jinwoo-H

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

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​134 $\color{#cf222e}{\Huge{\mathbf{−}}}$​13 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​121
Prod 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​82 $\color{#cf222e}{\Huge{\mathbf{−}}}$​26 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​56

ELI5

When we upgrade a relay server, we first ask every desktop connected to it to move to another server. We spread those requests over a time window, five minutes today. On a busy Asia server five minutes was too fast: the database got overloaded. This PR adds slower options, 15 and 20 minutes, so a busy server can be emptied gently.

What Changed

  • The same-cap rollout form now offers drain pace windows of 900000 (15 min) and 1200000 (20 min), alongside 300000, 60000 and 30000. The slow ones are allowed on every cell, Asia included. The faster-than-default ones are still US general cells only.
  • The relay cell now accepts a drain window up to 20 minutes (it was 5). It still spreads the drain messages evenly across the window: one every window / (hosts - 1).
  • Safety fix. When a cell refused a window, the drain script used to fall back to draining everyone at once, because "this image doesn't support pacing" and "this window is over my cap" both come back as the same 400. For a window above 5 minutes it now fails instead. Without this, asking for 20 minutes on a cell running today's image would have drained all ~2,000 hosts at once.
  • The canary rule is unchanged: a batch may drain at the canary's pace or slower. Slower than the default never needs a PASS pace verdict. A slow canary does not authorize faster batches.
  • Timeouts. After the last host leaves, the roll waits a full window of quiet before restarting the cell. A drain step therefore takes about twice the window. The step's timeout is now 15 min + window + (window - 5 min) when the window is over 5 min, so 40 min at 15 min and 50 min at 20 min. It is unchanged for the existing values. The cell job's overall limit goes from 90 to 120 minutes so a 20-minute drain fits.

Expected per-cell drain time (drain plus quiet wait): about 30 minutes at 900000 and about 40 at 1200000, against about 10 at 300000. For a ~2,000-host Asia cell that is about 2.2 hosts/s at 15 min and 1.7 hosts/s at 20 min, against about 6.3 at 5 min.

Why

On 2026-10-07, c28 (Asia, 1,901 hosts) drained at the 5-minute pace, about 6.3 hosts/s. It held database lock time over its bar for about 10 minutes and caused director errors. US cells drain about 650 hosts at about 2.2 hosts/s without trouble, so the fix is to bring big Asia cells down to that rate.

Alternatives considered:

  • Cap the rate in hosts/s instead of a window. That is a bigger change to the cell and to the canary authority format.
  • Only add the values to the workflow. Unsafe: today's cells reject them, and the old fallback would drain all hosts at once.

Caveat: a slower window works only on a cell already running an image with this change. That means a cell's next roll after this merges. The cell now reports its pace cap on /health (drainPaceWindowMaxMs; images without it are treated as 300000). The job reads that cap before isolating the cell and stops with the cell untouched if the requested window is higher. Re-dispatch at 300000.

This is evidence code. Merge it between cells, never during a wave. Merging voids any sealed canary authority or monitor, so the next wave needs a fresh canary.

Linked Issue

N/A (internal relay operations).

Visual Proof

N/A: rollout workflow and relay server change, no UI.

Testing

  • node --test over every cloud script test in cloud/package.json (pretest + test lists): 928/928 pass.
  • Relay vitest on regional-host-drain-app.test.ts and host-session-registry.test.ts: 92/92 pass. tsc --noEmit passes for apps/relay.
  • actionlint on both workflows: only the existing unknown blacksmith runner-label notices.
  • Automated tests added:
    • both new values pass the closed set;
    • they are allowed on Asia, mixed US/Asia and migration-only cells;
    • they must be named in the confirmation;
    • canary same-or-slower holds in both directions;
    • a 300000 canary with a non-PASS verdict still authorizes the slow paces;
    • the cell accepts 1200000 and rejects 1200001;
    • the drain script refuses the unpaced fallback for both new values;
    • the pace check stops an old-cap cell at 900000 and 1200000 with only a /health read, and runs before the isolate step;
    • the slowest drain step stays inside its one-hour ID token and leaves the rest of the job its 70 min;
    • the workflow's timeout expression, evaluated in bash per pace, is unchanged for the old values, covers twice each window plus 10 min, and fits inside the job limit.

Notes

No desktop, mobile, SSH or cross-platform impact. Old values behave exactly as before.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • N/A visual proof with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote impact considered (N/A)
  • Tests pass locally

…cell class

c28's 1,901-host drain at the 300 s pace (~6.3 hosts/s, 2026-10-07) held
database lock time over its bar for about 10 minutes. Add 15- and 20-minute
pace windows to the same-cap closed set, allowed on every cell class.

- The cell's /v1/admin/drain cap rises from 5 to 20 minutes.
- The drain script fails instead of falling back to an unpaced drain when a
  cell rejects a window above 300000, since an older image answers both with
  the same 400.
- The fast-pace US-only rule and the canary PASS rule apply only below the
  default; a canary still authorizes its own pace or slower.
- The restart-safe timeout adds the window's excess over 300000 (quiet starts
  after the last host leaves), unchanged at 300000/60000/30000; the job
  timeout rises from 90 to 120 minutes.
@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: dd7641cf-1637-4d1b-8cf3-52baa8edde01
📥 Commits

Reviewing files that changed from the base of the PR and between cbe8b4f and cb6720d.

📒 Files selected for processing (7)
  • .github/workflows/cloud-deploy-relay-production-same-cap-job.yml
  • cloud/apps/relay/src/app.ts
  • cloud/apps/relay/src/relay.blackbox.test.ts
  • cloud/dev/scripts/prepare-relay-production-capacity-canary.mjs
  • cloud/dev/scripts/prepare-relay-production-capacity-canary.test.mjs
  • cloud/dev/scripts/relay-production-same-cap-wave.test.mjs
  • cloud/docs/relay-workflows.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.


📝 Walkthrough

Walkthrough

The same-cap drain workflow now supports pacing windows up to 1,200,000 ms. The changes update window validation, canary pacing rules, and behavior when a cell rejects a paced drain request. Workflow timeouts and tests now account for longer windows. The documentation describes the available windows, cell restrictions, canary rules, and rejection handling.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to cb672

The slower drain windows have no confirmed merge-blocking issue in the reviewed change.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 7 files. (2 skipped: 2… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the main change: adding 15-minute and 20-minute slower same-cap drain paces for all cell classes.
Description check ✅ Passed The description is detailed and covers the required ELI5, changes, rationale, testing, visual proof, notes, and checklist sections. It explains the internal issue exception for the missing linked issu…
Full details: Docstring Coverage

Explanation

Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 7 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…not accept it

The cell advertises its drain pace cap on /health; the same-cap job reads it
before the isolate, so a pace above an old image's 300000 cap stops with the
cell untouched instead of isolated. Also refreshes two stale timeout comments
and pins the drain step under its one-hour ID token and the job's 70-min
remainder.
@Jinwoo-H
Jinwoo-H merged commit a07f4b2 into main Oct 7, 2026
23 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