Skip to content

hack: match the e2e gateway pool by org id and one regex, guard config size, keep pool counts in sync #9153

Closed

Description

@waynesun09

Problem

#9142 grew the DEV pool to 22 orgs. Rolling the new allowlist out to the e2e inference gateway showed three gaps in hack/setup-e2e-inference-gateway.sh:

  1. The config grows with the pool, up to a hard limit. The rendered config repeats the full repository list 6 times (two rate-limit keys, one allow rule per real model). At 23 orgs × 12 repos it is 50,827 bytes (12 orgs: 30,622). Secret Manager rejects a version over 65,536 bytes, and each extra org adds about 2 KB. So roughly 7 more orgs, or a larger DefaultPoolSize, breaks the secret write mid-run, after the busy check and the frozen diff have passed.
  2. The pool is listed by hand in three places, and nothing checks that they agree. POOL_ORGS / POOL_REPOS in the script, orgPool in internal/e2etest/testutil.go, and DevPoolOrgCount / DefaultPoolSize in pkg/behaviourtest/drivers/install/. ci(e2e): expand DEV pool to 22 orgs #9142 updated the gateway script, but the gateway itself was not redeployed in the same change, and the behaviour run got HTTP 403 on halfsend-14/test-repo-05. hack/setup-new-e2e-org.sh ends with "Uncomment ... in testutil.go orgPool" and never mentions the gateway script.
  3. The docs say a pool change is a plain re-run, but the script refuses it. New orgs are inserted before the STAGE org halfsend. The frozen-path diff only allows repos appended after the pool list, so a pool change exits 4 and needs --allow-frozen-change. The script header ("Re-running after a pool change adds a config secret version and rolls a new Cloud Run revision") and the "Pool change" bullet in docs/guides/dev/e2e-testing.md both say otherwise.

The pool names follow a fixed pattern (halfsend-NN/test-repo-NN, plus the STAGE org halfsend), so one anchored regular expression can replace the 276-entry list.

Scope

  1. Match the pool with one anchored regex instead of a list.
    • Build it from two counts in the script, POOL_ORG_COUNT (22) and POOL_REPO_COUNT (12). Do not list names by hand. For the current pool it is:
      ^halfsend(-(01|02|...|22))?/test-repo-(01|02|...|12)$
    • Write each number as an explicit alternative. Do not use [0-9]{2} or digit ranges. The rule must admit exactly the pool, so halfsend-00, halfsend-23 and halfsend-01/test-repo-13 are refused. Whoever owns a pool-shaped org name outside the pool must not get access.
    • Use it in every place the list is used today:
      • model allow rules: jwt.repository.matches('<regex>')
      • both rate-limit keys: default(jwt.repository, "").matches('<regex>')
    • The header comment keeps the counts, for example # 276 allowed repositories (23 orgs x 12 repos).
    • Temporary repositories still get added as exact names: jwt.repository.matches('<regex>') || jwt.repository in ["owner/name"]. Update mask_config and its comment, so that only that trailing exact-name list is masked in the frozen-path diff, and a changed regex or count stays visible.
  2. Keep the script's counts in sync with the behaviour pool.
    • Add a test to hack/setup-e2e-inference-gateway_test.sh that reads DevPoolOrgCount from slotpool.go and DefaultPoolSize from driver.go, and fails when POOL_ORG_COUNT / POOL_REPO_COUNT differ.
    • Add a Go test that orgPool equals halfsend-01 ... halfsend-<DevPoolOrgCount>.
  3. Size guard. After rendering the config, and before any change, fail with a clear error naming the byte count when it exceeds 65,536 bytes. Print the config size in the normal output. Add a test: an oversized config exits non-zero and makes no gcloud write.
  4. Regex tests in hack/setup-e2e-inference-gateway_test.sh, run against the rendered config's regex with grep -E (an anchored alternation behaves the same in RE2 and ERE):
    • all 276 pool names match;
    • these names are refused: halfsend-00/test-repo-01, halfsend-23/test-repo-01, halfsend-1/test-repo-01, halfsend-01/test-repo-13, halfsend-01/test-repo-00, halfsend-01/test-repo-1, xhalfsend-01/test-repo-01, halfsend-01/test-repo-01x, halfsend-01/test-repo-01/x, Halfsend-01/test-repo-01, halfsend-01-x/test-repo-01.
    • Update the existing "allows the 23 x 12 pool repositories" check to read the counts and the regex.
  5. Docs.
    • docs/guides/dev/e2e-testing.md: the "authorises each model with an exact-match list of jwt.repository values" bullet describes the anchored regex and says why it uses explicit alternatives.
    • The script header and the "Pool change" bullet: a pool change edits POOL_ORG_COUNT or POOL_REPO_COUNT and needs --allow-frozen-change, outside a release window, with the maintainers told first. Run --dry-run first: it shows the diff and exits 4.
    • hack/setup-new-e2e-org.sh next steps: add the gateway script step, and fix the orgPool wording to match how the list is kept now.

Out of scope: rate limits, models, API keys, and deploying to the live gateway. The first deploy after this change is a frozen change, run by an operator with --allow-frozen-change.

Done when

  • bash hack/setup-e2e-inference-gateway_test.sh passes, including the new regex, size and count-sync cases.
  • go test ./internal/e2etest ./pkg/behaviourtest/drivers/install passes.
  • hack/setup-e2e-inference-gateway.sh --print-config --with-vertex (with E2E_GCP_PROJECT_ID set) renders a config whose only differences from main's are the repository rules, the header and the comments.

Added for the PR takeover: pin the pool org ids

A rule that matches names alone trusts whoever holds an org name. If a pool org is deleted or renamed while the deployed rule still names it, a new owner of that name gets inference on the real models. Org ids are never reused, so pin them the way the fleet gateway pins repository_owner_id. Repository ids cannot be pinned: slot repositories are deleted and re-created for each lease.

  1. Rule.

    • Model allow rules: jwt.repository_owner_id in [<ids>] && jwt.repository.matches('<regex>').
    • Rate-limit keys: the same, with default(..., "") on both claims.
    • Measured on the live 23-org config: 50,827 bytes with the exact list today, 5,501 with the regex alone, 7,507 with the regex and the id pin. Each extra org adds about 100 bytes.
  2. Ids live in the script, one org=id per pool org. Never look them up at deploy time: that would pin whoever owns the name on that day. Current values (gh api orgs/<org> --jq .id):

    Org Id
    halfsend 273231846
    halfsend-01 286139071
    halfsend-02 286136132
    halfsend-03 286139209
    halfsend-04 286139284
    halfsend-05 286139354
    halfsend-06 286139421
    halfsend-07 298026865
    halfsend-08 298029010
    halfsend-09 298029468
    halfsend-10 298030162
    halfsend-11 298030745
    halfsend-12 298031207
    halfsend-13 351883647
    halfsend-14 353052683
    halfsend-15 353052733
    halfsend-16 353052777
    halfsend-17 353052812
    halfsend-18 353052850
    halfsend-19 353052883
    halfsend-20 353052926
    halfsend-21 353052961
    halfsend-22 353053001
  3. Check at every run, before any change and in --dry-run:

    • each pinned org's current id from gh api orgs/<org> must equal the pinned id;
    • a mismatch or a missing org stops the run with an error naming the org.
    • Tests: a stubbed mismatch exits non-zero with no gcloud write, and the org-count check also covers the number of pinned ids.
  4. Docs, in the "Pool change" bullet and hack/setup-new-e2e-org.sh next steps:

    • Adding an org: add its id (with the command above) along with the count.
    • Removing an org: lower the count and deploy before the org is deleted or renamed, so the deployed rule never names an org we no longer hold.
    • Say in one sentence why both the id and the name are matched.
  5. Rule tests add: a pool name with a wrong owner id is refused, and a pool name with no owner-id claim is refused.

Activity

  1. waynesun09 commented on Nov 6, 2026

    @waynesun09
    MemberAuthor

    /fs-code
    Do not sign off. No git commit -s, no Signed-off-by trailer. Scope is the issue body.

  2. fullsend-ai-triage commented on Nov 6, 2026

    @fullsend-ai-triage

    🤖 Finished Triage · ✅ Success · Started 1:03 PM UTC · Completed 1:05 PM UTC

    Commit: 21ba75e · View workflow run →

    Runtime: claude · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $0.18

  3. fullsend-ai-coder commented on Nov 6, 2026

    @fullsend-ai-coder
    Contributor

    🤖 Code · ⚠️ Cancelled · Started 1:03 PM UTC · Ended 1:05 PM UTC

    Commit: 21ba75e · View workflow run →

  4. changed the title [-]hack: guard e2e gateway config size and keep its pool in sync with the behaviour pool[/-] [+]hack: match the e2e gateway pool with one regex, guard config size, keep pool counts in sync[/+] on Nov 6, 2026
  5. added
    triaged
    on Nov 6, 2026
  6. fullsend-ai-triage commented on Nov 6, 2026

    @fullsend-ai-triage

    Re-triage confirms the earlier result: this issue is ready for implementation. All named files and constants exist, no open PR addresses it, and the scope and tests in the issue are specific enough to implement directly.

    Notes for the implementer

    • Check that --print-config --with-vertex differs from main only in the repository rules, header and comments, so a live --dry-run shows only the intended frozen change.
    • Run the size guard before any gcloud write, and ideally before the busy check and frozen diff, so an oversized pool fails early.
    • Keep pool changes behind --allow-frozen-change.
    • Open PR chore(e2e): split org pool setup into manual, enroll, and CI scripts #9061 (e2e org pool setup split) also edits hack/setup-new-e2e-org.sh and docs/guides/dev/e2e-testing.md. It is not a blocker, but expect a possible merge conflict in the docs changes.
    • No CI or workflow file changes are needed.
    • Per your comment, do not sign off commits.

    Proposed test case

    shell: all 276 pool names match the rendered regex; each listed near-miss is refused
    shell: POOL_ORG_COUNT/POOL_REPO_COUNT == DevPoolOrgCount (slotpool.go) / DefaultPoolSize (driver.go)
    shell: oversized config -> non-zero exit, error names byte count, no gcloud write
    go:    orgPool == halfsend-01 .. halfsend-<DevPoolOrgCount>
    

    Next steps:

    • /fs-code — agent creates a PR to implement this issue
    • /fs-code <your instruction> — agent implements with your specific guidance
    Previous run

    Triage found this issue ready for implementation. The three scoped items are clear, and each named file and constant exists in the repo. I found no duplicate issues and no open PR for this work.

    Notes for the implementer

    • The rendered config must stay byte-for-byte identical to main. Check this with --print-config --with-vertex before and after the refactor, so a live --dry-run still reports no changes.
    • Run the size guard before any gcloud write, and ideally before the busy check and frozen diff, so an oversized pool fails early.
    • Keep pool changes behind --allow-frozen-change, as the issue specifies.
    • The fix needs no CI or workflow file changes.

    Proposed test cases

    shell: oversized pool -> non-zero exit, error names bytes and org x repo counts, no gcloud write
    shell: script org/repo counts == DevPoolOrgCount (slotpool.go) / DefaultPoolSize (driver.go)
    go:    orgPool == halfsend-01 .. halfsend-<DevPoolOrgCount>
    regression: --print-config --with-vertex output unchanged vs main
    

    The /fs-code request in the comments asks for no sign-off (no -s and no Signed-off-by trailer). That applies to the implementation run.


    Next steps:

    • /fs-code — agent creates a PR to implement this issue
    • /fs-code <your instruction> — agent implements with your specific guidance
  7. fullsend-ai-coder commented on Nov 6, 2026

    @fullsend-ai-coder
    Contributor

    🤖 Finished Code · ⚠️ Cancelled · Started 1:03 PM UTC · Completed 1:05 PM UTC

    Commit: 21ba75e · View workflow run →

    Runtime: claude · Model: opus → claude-opus-5-5 · Effort: high

  8. waynesun09 commented on Nov 6, 2026

    @waynesun09
    MemberAuthor

    /fs-code
    Do not sign off. No git commit -s, no Signed-off-by trailer. Scope is the issue body.

  9. fullsend-ai-triage commented on Nov 6, 2026

    @fullsend-ai-triage

    🤖 Triage · ❌ Terminated · Started 1:07 PM UTC · Ended 1:09 PM UTC

    Commit: 7c9f11f · View workflow run →

  10. fullsend-ai-coder commented on Nov 6, 2026

    @fullsend-ai-coder
    Contributor

    🤖 Code · ❌ Terminated · Started 1:08 PM UTC · Ended 1:23 PM UTC

    Commit: 7c9f11f · View workflow run →

  11. added
    triaged
    and removed
    triaged
    on Nov 6, 2026
  12. fullsend-ai-triage commented on Nov 6, 2026

    @fullsend-ai-triage

    🤖 Finished Triage · ✅ Success · Started 1:07 PM UTC · Completed 1:09 PM UTC

    Commit: 7c9f11f · View workflow run →

    Runtime: claude · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $0.14

  13. changed the title [-]hack: match the e2e gateway pool with one regex, guard config size, keep pool counts in sync[/-] [+]hack: match the e2e gateway pool by org id and one regex, guard config size, keep pool counts in sync[/+] on Nov 6, 2026
  14. fullsend-ai-triage commented on Nov 6, 2026

    @fullsend-ai-triage

    🤖 Finished Triage · ✅ Success · Started 1:22 PM UTC · Completed 1:24 PM UTC

    Commit: 7c9f11f · View workflow run →

    Runtime: claude · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $0.18

  15. fullsend-ai-coder commented on Nov 6, 2026

    @fullsend-ai-coder
    Contributor

    🤖 Finished Code · ✅ Success · Started 1:08 PM UTC · Completed 1:23 PM UTC

    Commit: 7c9f11f · View workflow run →

    Runtime: claude · Model: opus → claude-opus-5-5 · Effort: high · Cost: $3.06

  16. added
    pr-open
    and removed
    triaged
    on Nov 6, 2026
  17. fullsend-ai-triage commented on Nov 6, 2026

    @fullsend-ai-triage

    An open PR already implements this issue: the single anchored regex built from the two pool counts, the count-sync checks against the behaviour pool, the config size guard, the Go orgPool test and the doc updates. The PR is not a draft.

    One gap to check during review: the PR description does not mention the owner-id pinning added under the PR takeover section. That covers the repository_owner_id rule, the per-run check of each org id, the stubbed id-mismatch tests, and the wrong-id and missing-claim rule tests. If the PR omits it, it will need a follow-up commit or a separate PR.

    Open PR #9061 also edits the e2e org setup script and the e2e testing guide, so expect a possible merge conflict in the docs. No CI or workflow file changes are needed.

    Addressed by:

  18. added a commit that references this issue on Nov 6, 2026
  19. added 2 commits that reference this issue on Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    pr-open

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions