Skip to content

feat(deploy): smoke a target through the edge: opt in as CI, then check the version and the route - #253

Merged
aRustyDev merged 3 commits into
mainfrom
feat/target-smoke
Nov 17, 2026
Merged

aRustyDev merged 3 commits into
mainfrom
feat/target-smoke

Conversation

@aRustyDev

Copy link
Copy Markdown
Owner

The second piece of deploying release candidates as Worker Previews (#195 stage E, ADR-0111): the smoke of a target, through
the edge. No deploy runs it yet. It is independent of #241.

Why

A target is reached only through the shared hostname, and only with the edge's pin cookie:

  • How CI gets the pin: the edge sets it on /_edge/opt-in/<audience>?target=<name> for a principal Access admitted there.
  • Without it, the answer is production's.
  • So a target's smoke must opt in first, then check that the answers really are the target's.

What it adds

scripts/edge-opt-in.sh <shared-origin> <audience> <target> <cookie-jar>:

  • Credentials: it opts in with the CI opt-in service token, EDGE_CI_CLIENT_ID/_SECRET, read from a 0600 header file,
    never from arguments. It writes the edge's pin to the cookie jar.
  • What it retries: only the refusals time can cure:
    • "that target does not exist or is not open to you", until the target's flag has propagated (up to 30 s);
    • a 503;
    • no answer.
  • What is final:
    • an Access 403 (empty body);
    • the edge's "not admitted";
    • any other status;
    • a 303 that sets no pin.
  • What it refuses before asking anything: an origin that isn't https, and an audience or target outside the edge's
    own grammar.

scripts/smoke-deploy.sh:

  • SMOKE_COOKIE_FILE: the pin goes with every request of both phases. The sign-in's cookies join it in one jar, so
    the data read reaches the same target.
  • SMOKE_EXPECT_ROUTE: phase 1 also requires the edge's x-thrust-route to name the target.
  • Without either, the smoke is unchanged.
  • One bug the new test caught: the name check spells its letters out, because in a UTF-8 locale [a-z] also
    matches capitals.

Tests

test-smoke-deploy.sh, under dash: 54 checks pass, in both the C and a UTF-8 locale.

The stub: smoke_stub.py --pin now stands for the edge with one target. Only a request carrying that target's pin
reaches it; any other gets production's version, x-thrust-route: prod, and an API that answers 421.

What the tests show:

  • through the edge, both phases reach the target;
  • without the pin, production's version fails the smoke;
  • a different route, or no route header, fails it;
  • the opt-in waits out propagation and a temporary 503, and gives up after its attempts;
  • each final refusal is not retried;
  • every usage error asks nothing;
  • the secret appears in no curl argv and in no output.

Hand mutants: 11 versions of the two scripts with a planted bug, and each fails the tests. The first run had one
survivor: retrying every 403 still matched the refusal cases' expected message. Those cases now require the message only
an immediate refusal prints.

Also passing:

  • every deps step (14);
  • every ci-scripts test (29), each run on its own with sh as dash;
  • test_plan_ci.py (5024).

Not shown locally: that the runner's curl (8.5.0) stores a __Host- Secure cookie from 127.0.0.1 over http, as
curl 8.7.1 does here. This PR's ci-scripts job is the check.

Next

scripts/deploy-target.sh, stacked on #241:

  1. wrangler preview;
  2. check the deployed bindings;
  3. flagship.py put;
  4. this opt-in and smoke, plus the control that a version nobody deployed fails;
  5. on failure, delete the Preview and its flag.

Refs #195

🤖 Generated with Claude Code

aRustyDev and others added 3 commits November 16, 2026 17:55
…ck the version and the route

The smoke of a Preview target must go through the shared hostname (ADR-0111): the edge sends a request to the target only with
a pin cookie, which it sets on /_edge/opt-in/<audience>?target=<name> for a principal Access admitted there. Without the pin
the answer is production's. Part of #195 stage E; no deploy runs these yet.

- scripts/edge-opt-in.sh <shared-origin> <audience> <target> <cookie-jar>:
  - asks with the CI opt-in service token (EDGE_CI_CLIENT_ID/_SECRET, in a 0600 header file, never argv), and writes the
    edge's pin (__Host-thrust_edge) to the jar;
  - asks again only for the refusals that time cures: the edge's "that target does not exist or is not open to you", given
    until the target's flag has propagated (up to 30 s), a 503, no answer;
  - every other answer is final: an empty-bodied Access 403, the edge's "not admitted", any other status, a 303 that sets
    no pin;
  - refuses, before asking anything, an origin that is not https, and an audience or target outside the edge's own grammar.
- scripts/smoke-deploy.sh:
  - SMOKE_COOKIE_FILE: the pin goes with every request of both phases. The sign-in's session cookies join it in one jar,
    so the read reaches the same target.
  - SMOKE_EXPECT_ROUTE: phase 1 also needs the edge's x-thrust-route to name the target.
  - Without either, the smoke is unchanged.
  - The new name check spells its letters out: in a UTF-8 locale `[a-z]` also matches capitals. The test found it.

Tests (test-smoke-deploy.sh, under dash: 54 passed, in the C and a UTF-8 locale). smoke_stub.py now also stands for the edge
with one target (--pin): only a request with that target's pin reaches it, and any other gets production's version, route and
an API that answers 421. Cases:
- through the edge, both phases reach the target;
- without the pin, production's version fails it;
- another route, or no route header, fails it;
- the opt-in waits out propagation and a transient 503, and gives up after its attempts;
- each final refusal is final, not retried;
- every usage error asks nothing;
- the secret is in no curl argv and in no output (seen through the existing argv-logging curl wrapper).
11 hand mutants of the two scripts each fail it. The first run had one survivor: retrying every 403 still matched the refusal
cases' fragment, so those cases now require the message only an immediate refusal prints.

Also: every deps step (14) and every ci-scripts test (29), run separately with sh as dash. plan-ci.py routes edge-opt-in.sh with
the other deploy scripts (test_plan_ci.py: 5024). A row in cicd.md.

Refs: #195
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@aRustyDev
aRustyDev merged commit 63a263c into main Nov 17, 2026
45 checks passed
@aRustyDev
aRustyDev deleted the feat/target-smoke branch November 17, 2026 03:42
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