Skip to content

feat(relay): drain pace window as a reviewed same-cap input, with drain-aware 503 gates - #25639

Merged
Jinwoo-H merged 4 commits into
mainfrom
relay-drain-pace-input
Oct 5, 2026
Merged

Jinwoo-H merged 4 commits into
mainfrom
relay-drain-pace-input

Conversation

@Jinwoo-H

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

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​613 $\color{#cf222e}{\Huge{\mathbf{−}}}$​52 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​561
Prod 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​687 $\color{#cf222e}{\Huge{\mathbf{−}}}$​104 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​583

ELI5

When we update a relay server, it first moves every connected computer to another server. Today it always spreads those moves over 5 minutes, even for US servers that could take them much faster. This PR lets the operator choose 5 minutes, 1 minute or 30 seconds when they start the roll. The default stays at 5 minutes, and the choice has to be typed into the confirmation, so nobody can pick a faster pace by accident.

What Changed

Before: the same-cap roll hard-coded DRAIN_PACE_WINDOW_MS: '300000'. A US cell's hosts came back to the director at about 2 per second. The roll then waited about 10 minutes for the drain and the quiet period after it. The post-roll health gate also counted every director 503. That included the drain-return lane's scheduled "come back in N seconds" answers, so a faster drain would have looked like an outage.

After:

  • New input. Deploy Relay Production Same-Cap has a drain-pace-window-ms input with three choices: 300000 (default), 60000 and 30000. The wave script checks it against that closed list.
  • Fast pace is limited to US general cells. A pace below 300000 is refused for Asia cells and migration-only cells. Asia drains are limited by how fast the receiving cells can accept hosts, not by the pace.
  • The pace is bound to what was reviewed:
    • A non-default pace must be written at the end of the confirmation, e.g. ROLL_RELAY_SAME_CAP <digest> <cells> drain-pace-window-ms=60000. A confirmation with no pace means 300000. Default rolls keep today's confirmation unchanged.
    • The canary authority now records its pace (format v2). A batch may run at the canary's pace or slower, never faster, so going back to 300000 mid-ladder needs no new canary.
    • Each cell job checks the pace again before it reads production.
  • The drain wait scales with the pace. The restart-safe timeout is now 15 minutes plus the pace (still exactly 20 minutes at the default). The quiet period already scales: it is ceil(pace / 5 s) + 1 samples in verify-relay-capacity-transition.mjs.
  • Each roll records its pace. The job saves the pace the cell actually accepted (0 if an older image fell back to an unpaced drain), when the cell reached restart-safe, and the host count. These go into the shadow gate's report.
  • The shadow gate (report only) judges a drain on counted, non-scheduled 503s against the minutes just before it:
    • Counting. Director 503s now come from Cloud Run's own request counter (run.googleapis.com/request_count, code 503). Cloud Monitoring aligns it per minute, so a brownout cannot truncate the count. A log read stopped at 20k of 10-01 c29's ~31k.
    • Scheduled 503s are subtracted, using the director's runtime counters. These are drain-return deferrals and sticky/placement answers to a host's own early retry (host-rate-limited, host-in-flight). Each 30 s sample is split across the minutes it covers.
    • The background is the median of the 10 same-day minutes before the drain. The 24 h/48 h baselines are gone.
    • Two pace checks:
      • nonDrain503Budget: two straight minutes over max(1.5×, +20) warn; over max(2×, +40) would-block. One minute over max(10×, 200) would-block on its own; any other single minute is a transient. This replaces the earlier separate peak check, which needed the pre-drain peak. That peak was its blind spot when a brownout was already under way.
      • drainDeferrals: Retry-After over 30 s warns, over 60 s would-block.
    • Empty answers are unverified. A director-metrics read that fails, hits its limit, or returns fewer samples than one instance emits (one per 30 s) makes both checks unverified. An empty answer is not a calm director.
    • Pace verdict. These two checks form the report's paceVerdict. The other checks (Cloud SQL, Asia pools, boot) stay as context.
  • Partial counts past a block line now block. A truncated count is a lower bound, so once it is over the line, more data only adds to it. 503 counts no longer truncate at all. The Cloud SQL FATAL count blocks on a truncated count that is already over its line, and the pool check blocks on any single sample over the SQL-failure line. The waiter-run rule still needs a complete run, because gaps in the data can join two separate runs into one.
  • A failed, blocked or near-empty canary cannot authorize a faster batch. seal_canary downloads the canary cell's shadow report and seals its paceVerdict. It trusts PASS only from a report on the same cell that drained at least 400 hosts at that pace; anything else seals UNVERIFIED. A batch below 300000 requires PASS; a 300000 batch is unaffected.
    • Why 400. A pace is an arrival rate (hosts / window). 400 is about half the 692–782 hosts a US general cell carried on 10-02, so a batch cell sees at most about twice the rate the canary tested.
    • Artifact names. The download name, the report path and the cell all come from the gate's normalized cell list, which is also what cell_1 uploads under. A padded cell-ids input can no longer silently miss the artifact.
  • Docs. cloud/docs/relay-workflows.md has the ladder procedure: 300 → 60 → 30 s, one canary-apply per rung, stepping down only after the canary's paceVerdict is PASS. 30 s also waits for the drain-return lane service time (feat(relay): report lane service times, 503 causes, per-site hold p99 and a director-vs-cell lock-wait split #25645). Each step records the drain rate, non-drain 503s per minute, lane deferrals and roll time. Four of the rung's bars cannot be read from this job and are listed there as such. Staging cannot rehearse a paced drain today (its capacity proof drains unpaced), so each rung's first use is one production canary.

Where the 503 gates live. The only gate that counted drain deferrals is the shadow gate in this job, and this PR rebuilds its 503 checks. The pre-drain sample's 500/min rule (apps/relay-ops/src/pre-drain-sample.ts) only looks at the 10 minutes before a drain, so it never sees one. The incident monitor already leaves 503s out of its director 5xx rule (incident-monitor-sources.ts:136). The "assign 503s above 1.5× background" auto-abort that the ops review criticised was in the superseded step-1 design, not in code.

Cell side. /v1/admin/drain accepts 0 to 300000 ms with no minimum (app.ts:577), and the cell spaces sends window / (hosts − 1) apart. Both 60000 and 30000 are therefore in range. No cell or director image change is needed.

Why

Per the step-1 decision (item 3), US drains are slow because of this fixed 300 s window, not because of the director's lock: the 10-02 wave drained at 2.2–2.8 hosts/s with the drain lane idle. At 60 s a US roll should drop from about 26 to about 18 minutes. Each step down also measures the drain lane under real load, which no canary can do.

Alternatives considered:

  • A free-form number: it would let a typo or an untested value through.
  • Always typing the pace in the confirmation: it would break every default-pace runbook for no extra safety, because a confirmation without a pace already pins 300000.
  • Requiring a canary at the exact batch pace: it would make the documented fallback ("set it back to 300 for the rest of the wave") cost a new canary.

Linked Issue

Internal relay redesign, step 1 (revised), item 3. No issue.

Visual Proof

N/A: workflow and ops-script change with no UI.

Testing

  • node --test on every cloud script suite in package.json test and pretest: 852/853 pass (top-level tests). The one failure, relay-load-control-peer.test.mjs, needs a built @orca-cloud/relay-contract dist in this worktree and is unrelated.
  • New tests cover:
    • the closed set, including rejected values;
    • US-only fast pace, including mixed batches and migration-only cells;
    • the pace bound into the confirmation in both directions, and in rollback;
    • canary pace ordering, and that a v1 or unpaced authority is refused;
    • that the dispatch options, the 10 cell jobs, the gate, seal and verify steps, the cell-class step and the timeout formula all match the script. The job's own cell-class block runs in a shell and refuses a disallowed pace;
    • the deferral subtraction and its minute attribution, the budget thresholds, the Retry-After bands, and an end-to-end case: a 30 s drain's 760 deferrals read as PASS, and the same 503s without deferrals read as WOULD_BLOCK.
  • actionlint on both workflows: clean apart from the custom runner label.
  • Automated tests added/updated, including the c29 per-minute shape, the 10-02 single-minute transients, the pre-drain median, the early-retry exclusion, the proportional minute split, and the sealed pace verdict (PASS, WARN, WOULD_BLOCK, missing report, another cell's report, unpaced fallback)

Replays (read-only). These reuse the review's harness (~/orca-lanes/rv-25639-data/replay.mjs). The cases are its 1002/cases.json and cases2.json (the final review's 19 windows), plus 10-01 c29 and c25. Run unchanged, the harness reports the 503 checks unverified, because its guard refuses gcloud auth print-access-token, which the Monitoring read needs. The copy used here differs only by also allowing that token call and GET requests to Monitoring timeSeries.

Results at the current head. All 30 overall verdicts and pace verdicts are identical to the runs before the per-minute peak check was folded into the budget:

window pre-drain median /min peak non-drain /min nonDrain503Budget drainDeferrals paceVerdict
c29-1001 1.5 6680 would-block (9 min over 41.5) pass WOULD_BLOCK
c15-1002 1 20 pass pass PASS
c16-1002 1.5 87 pass pass PASS
c19-1002 1.5 19 pass pass PASS
c20-1002 0.5 31 pass pass PASS
c21-1002 1.5 39 pass pass PASS
c22-1002 0.5 22 pass pass PASS
c23-1002 3 31 pass pass PASS
c24-1002 0.5 33 pass pass PASS
c26-1002 2.5 26 pass pass PASS
c25-1001 1 30 pass pass PASS
bad-c27-0923 0 9447 would-block (8 min over 40) pass WOULD_BLOCK
bad-c30-0924 0 6095 would-block (11 min over 40) pass WOULD_BLOCK
bad-c28-1001a 824 8136 would-block (12 min over 1648) pass WOULD_BLOCK
bad-c28-1001b 0 5999 would-block (9 min over 40) pass WOULD_BLOCK
herd-0928 9.5 70334 would-block (16 min over 49.5) pass WOULD_BLOCK
herd-0930 5.5 22055 would-block (14 min over 45.5) pass WOULD_BLOCK
ok-c7-0922a 0.5 6 pass pass PASS
ok-c7-0922b 1 14 pass pass PASS
ok-c29-1001-1035 1.5 20 pass pass PASS
ok-c29-1001-1256 4 39 warn pass WARN
ok-c29-1001-1715 0.5 112 would-block (4 min over 40.5) pass WOULD_BLOCK
ok-c8-1001 0.5 20 pass pass PASS
ok-c9-1001 1.5 35 pass pass PASS
ok-c10-1001a 0.5 36 pass pass PASS
ok-c10-1001b 0 22 pass pass PASS
ok-c13-1001 1.5 19 pass pass PASS
ok-c14-1001 2.5 76 pass pass PASS
ok-c7-1002a 1 21 pass pass PASS
ok-c7-1002b 0 25 pass pass PASS
  • Brownouts. Every brownout and herd is would-block on sustained minutes.
  • Clean rolls. All 21 clean rolls PASS on the pace checks; their largest single minute was 87. Two daytime Asia c29 windows on 10-01 read WARN and WOULD_BLOCK on sustained non-drain 503s at the default pace; their largest minute was 112. The 10-01 c28 window that began mid-brownout (median 824) still blocks on the sustained rule.
  • Blind windows. None: every window has its own pre-drain background.
  • Overall verdicts. On clean rolls these stay WARN or WOULD_BLOCK, from cloudSqlFatal and fleetPool:*. That is why the ladder reads paceVerdict.

Calibration, stated plainly: the +20/+40 margins and the two-minute rule were chosen with these replays in view. Clean rolls had single minutes up to 87 but never two consecutive minutes over +20.

Not done here (by design: no workflow dispatch from this PR): a paced roll. Staging has no paced-drain path, so the first 60000 rung is one production canary.

Review

One self-review pass on correctness, binding gaps, and backwards compatibility.

Agent skill upstream boundary

  • Not applicable

Notes

  • Evidence code: merging invalidates a running monitor. Both same-cap workflows and relay-production-same-cap-wave.mjs are in TRUSTED_EVIDENCE_CODE_PATHS (relay-evidence-code-provenance.mjs). Merging this PR invalidates:

    • any monitor dry-run evidence sealed before the merge (the rehome enable refuses it);
    • any same-cap canary authority sealed before the merge (also refused by the v2 format).

    Merge between rolls, with no monitor running or about to be consumed, then run a fresh canary. The shadow gate scripts are not in that set.

  • Default behaviour is unchanged: 300000, the same confirmation, and the same 20-minute timeout.

  • Shadow gate cost. The 24 h/48 h baseline reads are gone, replaced by one Monitoring read and a few director-metrics log reads; the gate took 15–31 s per cell in the replays. If a read fails, the 503 checks report unverified rather than guessing. The Monitoring read uses the job's deploy identity, the same one the pre-drain sample already uses for Monitoring.

  • coderabbit's "reject below-default applies when the cell falls back to an unpaced drain" (job :541-548): not applied. The fallback ignores the requested pace at every value, which is today's behaviour on an old image. A fast batch cannot reach it: it needs a PASS canary, which requires applied pace = requested pace on the same predecessor image every batch cell runs. The suggested exit would fire after the isolate and the unpaced drain, leaving a drained migration-only cell mid-wave with no apply resume. That is worse than the drain it objects to.

  • Not done (optional in the final review):

  • Not reported by this job: drain-to-reconnected p95, the drain-return lane's service time, over-cap cells, and selector compare-and-swap retries. These wait for the director observability work (revised step 1, item 1). The docs say to record them as unmeasured until then.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • N/A for visuals, with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path impact considered: N/A (CI workflow and ops scripts only)
  • Relevant tests pass locally; CI covers the rest

…in-aware 503 gates

The same-cap roll drained every cell over a fixed 300 s window, so a US roll
re-placed hosts at ~2/s and spent ~10 minutes draining and waiting for quiet.
The window is now a dispatch input from a closed set (300000, 60000, 30000),
defaulting to today's 300000.

- Below the default is refused for anything but US general cells; Asia drains
  are bound by their targets' accept rate, and migration-only cells hold no hosts.
- A non-default window must be named in the confirmation, the canary authority
  records it (v2), and a batch may run at its canary's window or slower only.
- Each cell job re-checks the window, scales the restart-safe timeout with it
  (15-min lease + window, unchanged at the default), and records what the cell
  applied and when it settled.
- The report-only shadow gate takes the director's drain-return deferrals out
  of the 503 count (window and baselines), adds the rung's 5-min non-drain 503
  budget and a Retry-After check, and reports the measured re-placement rate.
- relay-workflows.md documents the pace ladder and what each rung records.
@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

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: d2e5bfb3-9946-4851-8d4c-e626beb32526
📥 Commits

Reviewing files that changed from the base of the PR and between ffc84e6 and 85e7bcf.

📒 Files selected for processing (7)
  • .github/workflows/cloud-deploy-relay-production-same-cap.yml
  • cloud/dev/scripts/relay-production-same-cap-wave.mjs
  • cloud/dev/scripts/relay-production-same-cap-wave.test.mjs
  • cloud/dev/scripts/relay-same-cap-shadow-gate-verdict.mjs
  • cloud/dev/scripts/relay-same-cap-shadow-gate.mjs
  • cloud/dev/scripts/relay-same-cap-shadow-gate.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; 6 remain after this review.


📝 Walkthrough

Walkthrough

The same-cap deployment accepts drain pace windows of 300,000, 60,000, or 30,000 ms. Validation restricts faster windows to eligible cells, requires confirmation, and records the pace in canary authority. Cell jobs apply the selected pace and pass drain results and timing data to the shadow health gate. The gate evaluates drain-return deferrals separately from non-drain 503s and reports the associated judgments and drain metadata.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 85e7b

This change adds opt-in faster drain pacing, gated by cell eligibility, confirmation, and canary-sealed evidence. The default pace is unchanged. No actionable merge-blocking risk was identified.

Security Architecture Review

Security architecture risk: 🟡 Moderate · up to 85e7b

Faster drains have explicit cell, confirmation, and canary restrictions. However, reusable canary approval does not track changes to the health logic that now grants that approval. A later rollout can therefore reuse a stale passing result after those checks change.

Retained concerns

  • Medium · security · observed: The newly authoritative pace-verdict producer is outside the canary provenance boundary. TRUSTED_EVIDENCE_CODE_PATHS omits relay-same-cap-shadow-gate.mjs and relay-same-cap-shadow-gate-verdict.mjs, although their output now authorizes faster batches. A descendant commit changing only these checks can retain an older PASS authority without proving that the canary passes the current rules. The omission predates this PR, but its effect on accelerated-rollout authority is new.
Security review details

Security Blast Radius

  • inferred — The identified control-drift path affects accelerated production drains across an authorized batch of up to ten eligible US general cells. Consequences primarily concern placement availability through the shared director; the inspected path does not demonstrate data access or privilege escalation.

Security Findings and Attack Paths

  • inferred — A producer-only change to health thresholds, telemetry interpretation, or PACE_CHECKS can leave an earlier passing canary reusable because cross-commit verification compares only the listed trusted paths. An authorized dispatcher can then submit that older run for a faster batch. This is a stale-approval path, not a demonstrated unauthenticated network exploit.

Trust Boundaries and Controls

  • observed — The dispatch gate requires operations to be enabled and the main branch, and uses the production environment. Drain calls obtain an audience-bound identity token and send it as a bearer token. Exact confirmation and canary matching remain separate controls; none substitutes for complete coverage of the code producing a reusable approval.

Resilience and Maintainability Implications

  • observed — The older-image fallback records pace zero, which cannot satisfy a matching non-default canary report. Missing or non-passing pace evidence prevents faster-batch authorization while preserving the previous default-pace route. These recovery controls limit failure propagation but do not repair stale approval across health-code revisions.

Hardening Proposals

  • proposed — Extend the canary provenance boundary to both pace-verdict producer modules and require their changes to invalidate reusable authority. A focused contract test could check rejection when a descendant revision changes only health-evaluation code.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 35.42% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 48 functions across 6 files. (2 skipped: … 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 changes: a reviewed drain-pace input and drain-aware 503 gates for same-cap relay deployments.
Description check ✅ Passed The description is detailed and follows the template. It covers the change, rationale, visual proof, testing, review, agent-skill boundary, notes, and checklist. It states that no issue is linked; the…
Full details: Docstring Coverage

Explanation

Docstring coverage is 35.42% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 48 functions across 6 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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Drain-pace input and its binding. drain-pace-window-ms (300000 default / 60000 / 30000) is admitted only from that closed set, refused below default for anything outside SAME_CAP_FAST_DRAIN_PACE_CELLS (US general), and a non-default pace must be named at the end of the confirmation for canary, batch, and rollback.
  • Canary authority v2. The authority records its pace; a batch may run at the canary's pace or slower, never faster, and a v1/unpaced authority is refused. This is what makes falling back to 300000 mid-ladder need no new canary.
  • Workflow plumbing. The input reaches validate, verify-canary, create-canary, and all ten cell jobs; each cell job re-checks the pace via cell-class before reading production; the drain step records the applied pace (0 on an older unpaced image) and the restart-safe settle stamp; the transition timeout scales as 900000 + pace (exactly today's 1200000 at the default).
  • Drain-aware shadow gate. drainReturnByMinute reads the director's own counters, withoutDrainDeferrals takes them out of the 503 count in the window and both baselines, and the new nonDrain503Budget / drainDeferrals checks plus the drain report block record the rung. The subtraction is sound: drain-return-deferred is recorded exactly once per deferred request and always returns HTTP 503 (deferDrainReturn), so the counter is 1:1 with the http.request.status=503 entries it is removed from.
  • Tests and docs. New coverage is exact (closed set with rejected values, US-only fast pace, confirmation binding both directions, canary pace ordering, workflow/script agreement, the rung budget thresholds, and an end-to-end fast-drain PASS versus the same 503s as WOULD_BLOCK). All changed and adjacent cloud suites pass locally.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

…minutes, and seal the canary's pace verdict

Review of #25639 replayed the shadow gate: it read 10-01 c29 as unverified (the
log read stopped at 20k entries), false-blocked 10-02 c22, and was blind on four
cells whose 24 h/48 h baseline held an incident.

- Director 503s now come from Cloud Run's request_count, aligned per minute by
  Cloud Monitoring, so volume cannot truncate the count.
- The background is the median of the 10 same-day minutes before the drain;
  the 24 h/48 h baselines are gone.
- Scheduled 503s come out: drain-return deferrals and sticky/placement answers
  to a host's own early retry (host-rate-limited, host-in-flight), each split
  across the minutes its 30 s sample covers.
- The rung budget counts only sustained breaches: two straight minutes over
  max(1.5x, +20) warn, over max(2x, +40) would-block.
- The report carries a paceVerdict over the three pace checks. seal_canary
  downloads the canary cell's report and seals that verdict; a batch below the
  default pace needs PASS, from a report on the same cell that drained at that
  pace.
- Docs: the step-down rule reads paceVerdict, 30 s waits for the lane service
  time (#25645), and the staging step is dropped since staging drains unpaced.

Replayed read-only: 10-01 c29 would-block (9 minutes over 41.5/min); all nine
10-02 cells and 10-01 c25 paceVerdict PASS.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

🟠 Major · Reject below-default applies when the cell… · cloud-deploy-relay-production-same-cap-job.yml:541-548

.github/workflows/cloud-deploy-relay-production-same-cap-job.yml:541-548
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Reject below-default applies when the cell falls back to an unpaced drain.

An older predecessor image can reject paceWindowMs with HTTP 400. The drain helper then sends {v: 1, graceMs: 0} and reports an applied pace of 0. This job exports that value but does not compare it with the requested pace. The transition verifier uses the requested pace only to require a quiet window, so the cell can proceed through apply and restore after an unpaced drain. A valid canary on another cell does not prevent this; the later shadow gate is report-only. HostSessionRegistry.drain sends every target immediately when the pace is 0, and the rollout notes record an approximately 800-host unpaced drain pinning the director at its 400 in-flight cap.

For non-default applies, fail before continuing when the applied pace differs from the requested pace.

Suggested fix
           echo "drain-applied-pace-window-ms=$(jq -er '.paceWindowMs' <<< "${DRAIN_RESULT}")" \
             >> "${GITHUB_OUTPUT}"
+          if test "${DEPLOY_MODE}" = apply \
+            && test "${DRAIN_PACE_WINDOW_MS}" != 300000 \
+            && test "$(jq -er '.paceWindowMs' <<< "${DRAIN_RESULT}")" != \
+              "${DRAIN_PACE_WINDOW_MS}"; then
+            echo "cell did not apply the requested drain pace" >&2
+            exit 1
+          fi
           # Restart-safe means an empty runtime for a whole pace window after the drain; leases

ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f81b7147-3e25-42b6-ba94-c1fd77688eb7
📥 Commits

Reviewing files that changed from the base of the PR and between caddb0c and c6505e2.

📒 Files selected for processing (7)
  • .github/workflows/cloud-deploy-relay-production-same-cap.yml
  • cloud/dev/scripts/relay-production-same-cap-wave.mjs
  • cloud/dev/scripts/relay-production-same-cap-wave.test.mjs
  • cloud/dev/scripts/relay-same-cap-shadow-gate-verdict.mjs
  • cloud/dev/scripts/relay-same-cap-shadow-gate.mjs
  • cloud/dev/scripts/relay-same-cap-shadow-gate.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; 1 remain after this review.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues — one minor suggestion inline.

Reviewed changes

  • Rebuilt the shadow gate's 503 accounting: director 503s now come from Cloud Monitoring's run.googleapis.com/request_count (per-minute ALIGN_DELTA/REDUCE_SUM) instead of a log read that truncates, and scheduled 503s (drain-return deferrals plus sticky/placement host-rate-limited/host-in-flight) are split across the minutes their 30s intervals cover and subtracted from the observed and background counts.
  • Replaced the 24h/48h baselines with the same day's 10 pre-drain minutes: nonDrain503Budget judges against their median with a two-consecutive-minute rule, director503 against their peak, and both thresholds were re-tuned with replay evidence.
  • Added a paceVerdict over the three pace-movable checks (director503, nonDrain503Budget, drainDeferrals); the canary authority (v2) seals it, and a batch below the default pace now requires PASS.
  • Bound the sealed verdict to the canary cell's own report (canaryPaceVerdict): a report from another cell or pace, or an unpaced fallback, seals UNVERIFIED; seal_canary downloads the artifact and passes --shadow-report.
  • Extended the shadow gate arguments and report with the applied pace, settle time, host count, and the pre-drain background; updated the ladder procedure and tests.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

continue-on-error: true
uses: actions/download-artifact@v4
with:
name: relay-same-cap-shadow-gate-${{ inputs.cell-ids }}-${{ github.run_id }}.json

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The canary's shadow artifact is uploaded under the normalized cell id (inputs.target-cell-id = fromJSON(needs.gate.outputs.cells)[0]) but downloaded here under the raw inputs.cell-ids. When those differ — a trailing space or comma in the dispatch input, which validateSameCapWave trims and accepts — the download misses silently (continue-on-error), create-canary seals UNVERIFIED, and a non-default batch is then refused even though the canary's paceVerdict was PASS.

Technical details
# Canary shadow artifact name uses the raw cell input; the upload uses the normalized cell

## Affected sites
- `.github/workflows/cloud-deploy-relay-production-same-cap.yml:372` — download `name:` uses `inputs.cell-ids`.
- `.github/workflows/cloud-deploy-relay-production-same-cap-job.yml:864` — upload `name:` uses `inputs.target-cell-id`.
- `.github/workflows/cloud-deploy-relay-production-same-cap.yml:384` — `--shadow-report` path also uses `inputs.cell-ids`.

## Required outcome
- The download name and the `--shadow-report` path must use the same cell token the job uploaded under, so a normalized-but-not-byte-identical `cell-ids` input cannot silently miss the artifact.

## Suggested approach (optional)
- `seal_canary` already declares `needs: [gate, cell_1]`, so it can use `${{ fromJSON(needs.gate.outputs.cells)[0] }}` (or a dedicated job output) for the artifact name and the `--shadow-report` path.

…shadow gate's Cloud SQL and pool checks

A truncated FATAL count is a floor, and one runtime sample over the SQL-failure
line is a fact, so neither waits for a complete read. The waiter-run rule still
needs a complete run, since holes can join two runs into one.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

This run re-reviewed the single commit since the prior pullfrog review (c6505e2 → ffc84e66), a fix to the shadow gate's verdict helpers.

  • Partial counts past a block line now block. judgeCloudSqlFatal tests the Cloud SQL FATAL count against the block line before its truncation/failure guard, and judgePool tests a sample over the SQL-failure line before its truncation guard, so a read that is only a lower bound and already over the line blocks instead of reporting unverified.
  • The consecutive-sample rule stays on complete runs only. The pool waiters rule is unchanged — a hole reads as a recovery, so it is still judged only when the run is whole.
  • Tests cover both directions. A truncated count over the line blocks while one under it stays unverified; the new pool cases add a run read across holes and a single over-line sample. The changed suite passes 26/26 locally.

Pullfrog  | Fix it ➔ | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

…y; one median-based 503 check

From the final review of #25639:
- canaryPaceVerdict seals PASS only from a report that drained at least 400
  hosts (about half a 10-02 US cell), so a near-empty canary cannot authorize
  a fast batch.
- A director-metrics sub-window with fewer samples than one instance emits
  is unverified, so an empty or short Logging answer is never a calm drain.
- seal_canary names the shadow artifact, report path and cell from the gate's
  normalized cell list, as cell_1 uploads it.
- director503 folds into nonDrain503Budget as a single-minute spike rule,
  max(10x median, 200), dropping the pre-drain peak statistic. All 30 replayed
  windows keep their verdicts.
@Jinwoo-H
Jinwoo-H merged commit f1ed355 into main Oct 5, 2026
40 of 43 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