Skip to content

test(relay): load generator can send two concurrent assigns per host (--duplicate-assign-probes) - #27107

Merged
Jinwoo-H merged 1 commit into
mainfrom
relay-load-duplicate-assign-probes
Oct 11, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
relay-load-duplicate-assign-probes

Conversation

@Jinwoo-H

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

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

ELI5

The staging load generator can now ask the relay "which cell?" twice at the same moment for one test desktop. That reproduces, on purpose, the rare case where two relay directors each pick a different cell for the same desktop. The staging step-5 run then checks the relay cleans it up.

What Changed

  • New flag --duplicate-assign-probes N (with --duplicate-assign-hold-ms, default 20 s) on cloud/dev/scripts/load-relay-controls.mjs. It needs --director-origin.
  • After the ramp, for each of N extra test hosts it:
    • sends two concurrent fresh /v1/assign calls;
    • connects the host with the first answer;
    • if the second answer named another cell, connects a twin peer with the same keys to that cell, holds it half-open for the hold time, then closes it. That is what a desktop seated on both cells looks like.
  • The final report gains duplicateAssign: probes, answers, splits, same-epoch splits, both-joined count, refusal and close codes, and the split hosts with their two answers (synthetic load hosts), so the operator can compare ledger rows afterwards.
  • Probe hosts are kept outside the run's control count. When a demotion closes one, it re-assigns through the director. Existing run gates are unchanged.
  • RelayLoadControlPeer takes an optional keys (for the twin) and connect(assignment) (use this answer instead of asking the director).

Before: the equal-epoch gate in the staging runbook could only be watched in a production canary. After: it can be driven on staging.

Why

Two directors mint the same epoch only when two assigns for one host reach two director instances within a poll. No existing probe does that, and Cloud Run cannot target an instance. Two parallel requests are the only way to get there.

When both land on the same instance, the second is refused by that instance's in-flight check. So a pair where both answers succeed and name different cells is direct evidence the case happened. That beats inferring it from logs.

Linked Issue

N/A (internal step-5 staging runbook, §6).

Visual Proof

N/A: a test-harness script change with no UI.

Testing

  • Automated tests added: relay-load-duplicate-assign.test.mjs (same-epoch split, different-epoch split, refused second assign, refused twin); a profile bounds test; and a peer test that a twin shares the host id and connects with the given assignment without calling the director. That last test fails if connect(assignment) is ignored.
  • The cloud node --test suite from cloud/package.json passes locally: 756/756.
  • Not run against staging yet; that is the runbook step.

Review

Agent skill upstream boundary

  • Not applicable.

Notes

Only the load generator changes; nothing runs in production. The cross-platform impact is nil, since this is a Node script run on Linux runners.

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/shortcut impact considered (N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build (CI will cover; cloud/ is outside root lint and format)

@coderabbitai

coderabbitai Bot commented Oct 10, 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: 66a134cc-c2f3-4b09-b35d-db2ab5c92f88


📥 Commits

Reviewing files that changed from the base of the PR and between 6128ceb and 3600673.



📒 Files selected for processing (1)
  • cloud/package.json


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




📝 Walkthrough
📝 Walkthrough

Walkthrough

The relay load-control scripts add configurable duplicate-assignment probes. Each probe requests two assignments for a primary peer and can use a twin peer with the same keys to test a second cell assignment. The scripts record assignment refusals, cell splits, twin connection results, and reconnect counts. Probe peers are included in shutdown, and the root test command now runs the probe tests.



Priority: ⬇️ Low

Merge Risk: 🟡 Moderate · up to 36006

The duplicate-assignment probe can report a two-cell join after the primary has disconnected, potentially misleading staging validation. Resolve or explicitly accept this before merging.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 7 files. (1 skipped: 1… 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 relay load-generator change and the new duplicate-assignment probe flag.
Description check Passed The description covers the required explanation, changes, rationale, testing, visual-proof exception, scope, and checklist. It also states that staging testing remains pending. The internal issue refe…

Full details: Docstring Coverage

Explanation

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


  • Fix all pre-merge checks with AI
  • Autofix · 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.

@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.

Actionable comments posted: 1

🔇 Additional comments (1)
cloud/dev/scripts/relay-load-duplicate-assign.mjs-61-63 (1)

61-63: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

⚠️ Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

Start each twin's hold when that twin joins.

If one pair connects quickly and another pair takes longer, the first twin stays open for the slower pair's connection time plus holdMs. With many probes, the configured hold duration does not bound a twin's occupancy. Start a per-twin hold timer after its successful connection, then shut down that twin when its timer expires.


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: cb723a6a-2b1f-4386-9bb1-7be04ed3cadc
📥 Commits

Reviewing files that changed from the base of the PR and between b4d5b7d and 6128ceb.

📒 Files selected for processing (8)
  • cloud/dev/scripts/load-relay-controls.mjs
  • cloud/dev/scripts/relay-load-control-peer.mjs
  • cloud/dev/scripts/relay-load-control-peer.test.mjs
  • cloud/dev/scripts/relay-load-duplicate-assign.mjs
  • cloud/dev/scripts/relay-load-duplicate-assign.test.mjs
  • cloud/dev/scripts/relay-load-profile.mjs
  • cloud/dev/scripts/relay-load-profile.test.mjs
  • cloud/package.json

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

Comment on lines +53 to +55
await twin.connect(second)
result.joinedBoth++
twins.push(twin)

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Confirm that both controls overlap before counting a join.

If the primary closes while twin.connect(second) runs, Line 54 still increments joinedBoth. The report then claims a two-cell join that did not occur. Check that the original primary control is still open when the twin joins, and record a failed overlap separately. A later director reconnect must not count as the original first-cell connection.

…(--duplicate-assign-probes)

Rebased onto main as one commit; kept both sides of the package.json test-list conflict with #27096.
@Jinwoo-H
Jinwoo-H force-pushed the relay-load-duplicate-assign-probes branch from 6128ceb to 3600673 Compare October 10, 2026 23:43
@Jinwoo-H
Jinwoo-H merged commit 6404b7e into main Oct 11, 2026
27 of 44 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