Repository navigation
feat(infra): the deploy workflow, the fleet promote entrypoint and production runbooks - #521
Conversation
|
Codex review (GPT 6.1 Sol, xhigh), two rounds before the first push. Round one:
Round two (on those fixes):
|
5d5527c to
ed438c6
Compare
f83df62 to
73e25c0
Compare
|
Codex review, round three (on the round-two fixes). Four findings, all fixed in the force-pushed commit:
|
73e25c0 to
6dce581
Compare
ed438c6 to
54bf960
Compare
|
Codex review, round four (blocker and major only, on the round-three fixes). Five findings, all fixed in the force-pushed commits on #520 and #521:
|
6dce581 to
9091571
Compare
|
Codex review, round five (a confirmation pass on the slot redesign, blocker and major only). One finding, fixed in
|
9326f0d to
9445ac1
Compare
|
Codex review, last check (on round five's guards). One finding, fixed in
The reviewer found nothing else across first release, plain release, re-run, rollback, unfinished promotion, overlap, undo and seal. |
9445ac1 to
094bf5e
Compare
|
Codex review, final narrow check (on recording the release before deploying). One finding, handled in
The reviewer found nothing else in this change: no stranded budget, no hosts unable to manage the fleet's tasks, and no leaks into the public log. |
54bf960 to
4d7c2db
Compare
094bf5e to
7875720
Compare
…oduction runbooks Nothing could deploy the CDK stacks, the spike promoted the fleet with an inline `node -e` script, and the docs said production was unbuilt. .github/workflows/deploy.yml runs on workflow_dispatch from main only, behind the `production` environment's reviewer, one run at a time. It assumes the deploy role through OIDC, stops promote tasks a cancelled run left behind, records the release as pending, builds the reproducible image, deploys the base stack, pushes the image with crane (a rollback finds its tag and must match its digest), deploys the app stack pinned to the digest with the promoted release as its previous revision, promotes the fleet, and confirms the service's primary deployment. Only merged commits deploy. An SSM parameter only the workflow writes records the promoted release and, while one is unfinished, the release being promoted, each with the management secret slot it reads and the previous release it was deployed beside. A release is pending from before anything deploys until its promotion. Releases take their previous settings from the record, never from the deployed stack, so a run that deployed but did not promote cannot drop the revision the fleet still runs. A re-run reuses its release's settings, and while a promotion is unfinished only re-running it or rolling back to the promoted release may deploy. Run logs are public: the account id, certificate and alert addresses are environment secrets so they are masked, stack outputs and resource ids are filtered out, and the promote task's output stays in CloudWatch. `node dist/fleet.js promote <revision>` runs Fleet.promote as a one-off host task after ECS settles: it stages the revision, waits up to five minutes for its hosts to warm spares, and promotes it. It moves rollout rows only, so it needs no task provider; it refuses a revision no host has registered and returns at once for one already promoted. A release's deployment revision is its commit. Rotating the management secret writes the new secret into the secret's idle slot, where no running host looks, then takes an overlap deploy that moves to that slot and a sealing deploy. Each needs a revision distinct from the running one or the ECS provider refuses to start, so the workflow's rotation input suffixes them (<commit>-overlap-<run>, <commit>-seal-<run>). A failure or rollback at any step leaves both slots readable. While a rotation is under way, only its seal or an overlap that undoes it may deploy, and a superseded rotation run cannot be re-run. docs/OPERATIONS.md gains setup, deploy, rollback, restore and rotation runbooks and names the host log group. The restore runbook says what Neon's branch restore does not cover: Object Storage, and fleet rows for tasks ECS has forgotten. ADR-0012 records the production topology; the "not built" notes now say written but not yet deployed. Part of #415. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
7875720 to
19320d4
Compare
## What changed The server, its company exec tasks and fleet promotion now run on Bun 1.4.4 in production, the version the root `package.json` pins. People notice nothing: patch code still runs in workerd and the CLI stays on Node. CI now tests what production runs: the offline suite on Bun, every CI lane's server on Bun, and the built image itself. Closes #1040 Stacked on #1122 (`bun/seams`), which sits on #1120 (`bun/fmt`). #1122 fixes the stale-stop Supervisor test that failed only on Bun. This PR's `test (bun)` runs it, and every other server test, without skipping. ## Look at **1. How Bun gets into the image.** The runner stage is `oven/bun:1.4.4-slim`, pinned by digest. Its `bun` is byte-identical to the binary `pnpm-lock.yaml` pins (sha256 `10702245…`), which is the one CI's tests run on. `scripts/build-server-image.mjs` refuses a runner whose tag names another version than `"bun": "runtime:<version>"`, or whose binary isn't the lockfile's. Users stay as #1040 describes: the image's `bun` user is uid 1000 for hosts, and exec tasks run as root and drop each workerd to its own uid. Node 24 stays as the builder stage. **2. Rolling back across the runtime change.** Three places hardcoded `node`, and each would have broken a deploy or a rollback: | Seam | Before | Now | |---|---|---| | The host's ECS provider overrode every exec task's command with `node dist/exec.js` | A Bun host would start the previous release's Node spares with Bun, or the reverse | No override: each release's task definition names its own runtime | | `deploy.yml` promoted with `node dist/fleet.js` | A Bun-only image couldn't promote | Promotes with the `fleetCommand` the image build recorded (present since #521), so a rollback to a Node release promotes with `node` | | Older hosts still send `node dist/exec.js` | — | In the Bun image, `node` falls back to Bun (the base image's `bun-node-fallback-bin`), so a rolled-back Node host still starts this release's spares | A scratch run (not in the repo) of a mixed fleet on one TLS+SCRAM database: - host A on the **Node** image from `main`, host B on the **Bun** image, sharing tasks; - `bun dist/fleet.js promote` promoted B; - the Node image's own `node dist/fleet.js promote` rolled back to A; - both hosts exited on SIGTERM. **3. The two images, built locally and booted the same way.** Each image's rootfs ran under bwrap as uid 1000, with the server as PID 1, against a local Postgres that takes only TLS (verify-full, scratch CA) and SCRAM. The machine was shared and loaded, so treat the numbers as relative. | | Node image (`main`) | Bun image (this PR) | |---|---|---| | Compressed layers (what ECR stores and Fargate pulls) | 187.0 MB | 190.0 MB | | Unpacked | 526 MB | 488 MB | | Boot, process start to `/healthz` 200, median of 7 | 1,228 ms | 996 ms | | RSS once ready, idle, median | 208 MiB | 167 MiB | | SIGTERM to exit, idle, median | 18 ms (exit 130) | 16 ms (exit 130) | **4. Which runtime each commit's server runs on in the rollback rehearsal.** The rehearsal harness stays on Node, as #1121 left it. Each checkout's server runs on the runtime its own `apps/server/package.json` `start` script names: the same file that says how that commit runs, `node dist/start.js` before this PR and `bun dist/start.js` from it. So this PR rehearses live (Node) → this PR (Bun) → live (Node) → this PR (Bun); once a Bun release is live it is Bun throughout. Reading it from each checkout, not from the harness, keeps a later rehearsal across this PR honest in either direction. ## How it was verified **CI, new or changed:** - `test (bun)` runs `pnpm test:bun`: the offline suite under `bun --bun vitest`. `vitest.bun.config.ts` names the 15 Node-only files and says why: 13 CLI process and dev-loop tests, `packages/sdk/src/install.test.ts` and `lint/rules.test.ts`. `test (22)`, `test (24)` and `test (26)` are unchanged and still run every file. Nothing else is skipped: #1122 fixed the one real Bun-only failure, and the other (`RequestEvents`) was a local port probe that CI doesn't have. - `image` (server-image.yml) now loads the built image and runs `scripts/server-image-smoke.mjs` with Docker: - two hosts on two revisions boot from the default command, as uid 1000, against a TLS-only, SCRAM-only Postgres; connecting by IP (not in the certificate) and without TLS are refused; - `bun dist/fleet.js promote` promotes the staged revision, then rolls back; - both hosts and the exec task exit on SIGTERM, not SIGKILL; - the exec supervisor runs as root with AppStack's dropped capabilities, and its standby workerd runs as its own uid; - `node` in the image runs Bun 1.4.4. - `browser` (tier 1 and 2 pages), `cli-smoke`, `tier2-smoke` and `clerk-live` (live Clerk) now start their server on the pinned Bun; the CLI stays on Node. - `rollback-rehearsal` starts each build's server on the runtime its `apps/server/package.json` start script names, so this PR rehearses live (Node) → this PR (Bun) → live (Node) → this PR. It runs here because the rehearsal script changed. - `NodeCryptography.test.ts` gains a credential and an agent retry copy sealed on Bun 1.4.4. Node's lanes open them, which is the rollback direction; the Bun lane opens the Node-sealed fixtures already there. **Locally:** - `pnpm lint`, `pnpm typecheck`, infra tests, `EcsTaskProvider.test.ts`, and the crypto fixtures on both runtimes. - `pnpm test:packed-tier2-e2e` with the server on Bun: PASS (packed init, both dev mounts, publish, two-viewer sync, keyed retry, sharing, files, members, CSV). - The `browser` lane with the server on Bun: 53 tests passed across `tier1`, `stream`, `server-subscriptions` and `starting` (local fleet, idle release, host restart, HTTP/2 ingress). One `tier1` test failed only on a stray `GET /` to its foreign-origin harness port. That's T3 Code's local port probe, which CI doesn't have, and that server is the harness's own, on Node. - The image smoke, end to end, through a scratch stand-in for Docker (bwrap and unshare; Docker isn't usable on the build machine), plus the mixed Node/Bun fleet above. - TLS and SCRAM through Effect's sql-pg, on both built images. Each connects only with the scratch CA, and refuses an unknown CA ("unable to verify the first certificate"), an IP the certificate doesn't name, a wrong SCRAM password, and plaintext. - The real `@aws-sdk/client-ecs` against a loopback endpoint on Bun: SigV4-signed, and the response parsed, the same as on Node. The S3 client already runs on Bun in the content-store contract tests. - Process identity and reap: the image's exec entrypoint as root in a user namespace with a uid range. The supervisor stays root; workerd runs as uid 60000 and is gone within ~200 ms of SIGTERM. Started as `node dist/exec.js`, the process is `/usr/local/bin/bun`. **Shown only in production:** - Neon itself: the local Postgres stands in for its TLS and SCRAM. - The task role's credentials through ECS's container credentials endpoint, and the Clerk production instance. - Fargate's CPUs: no AVX2 risk. Bun 1.4's x64 releases are baseline-only, and the pinned `oven/bun:1.4.4-slim` image ships the `x64-baseline` binary, byte-identical to pnpm's pin. That was checked in review against Bun's v1.4.4 slim Dockerfile. - Memory over several hours. - Not done here, as #1040 scopes it: `BunHttpServer` stays a separate, measured follow-up (`Bun.serve` closes silent connections after 10 s unless streams set `idleTimeout: 0`). The server keeps `@effect/platform-node` through node:http compat, as the 2026-10-28 trial ran it. ## Release impact - [ ] **Breaking** — requires action from anyone already running this - [x] **Not breaking** — no action required The runtime under the server changes; nothing anyone runs or calls does. The CLI, the API and the schema are unchanged. - **What does a revert leave behind?** No data in a new shape: no migration, and rows are written by the same code on either runtime. Credentials sealed on Bun open on Node (the new fixture runs on every Node lane). In ECR, the Bun image stays tagged with its commit. Exec task definitions from the Bun release stay registered (as every release's do) and name `bun dist/exec.js`. - **Does the release before it still work with that?** Yes. A rollback runs the Node release's own task definitions and promotes with its own `node dist/fleet.js`. While its hosts still replenish this release's spares, they start them with `node dist/exec.js`, which the Bun image runs on Bun. The rollback rehearsal and the mixed-fleet run above exercise that path. Not `one-way`. Built by Claude Opus 5.5 (xhigh effort) in T3 Code, via Claude Code. --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
What changed
Nothing could deploy the CDK stacks. The spike promoted the fleet with an inline
node -escript, and the docs still said production was unbuilt..github/workflows/deploy.ymlruns onworkflow_dispatchfrommainonly. It is gated by theproductionenvironment's reviewer and runs one at a time (concurrency group). It:main, and assumes the deploy role through OIDC;server-image.ymlsteps);crane, tagged with the commit. On a rollback the tag already exists, and the run checks the rebuilt digest matches it;node dist/fleet.js promote <revision>as a one-off task from the host task definition, after ECS has settled, and records the release as promoted;The release record. The SSM parameter
/patchy/production/promoted-releaseis written only by the workflow, never by CloudFormation. It holds the promoted release and, while one is unfinished, the release being promoted, each with the management secret slot it reads and the previous release it was deployed beside. A release is pending from before anything deploys until its promotion. A release is marked pending before promotion and promoted after. Each release takes its previous settings from this record, not from the deployed stack: a run that deployed hosts but didn't promote leaves the fleet on the release before it. A re-run reuses its release's recorded settings. While a promotion is unfinished (failed, timed out or cancelled), the workflow refuses any other release until that run is re-run or the promoted commit is released again.Fleet promote.
Fleet.promote(inpackages/execution) stages the revision, waits up to five minutes for its hosts to warm spares, and promotes it. It only moves rollout rows, so it needs no task provider (the spike's script built a whole ECS provider with hand-fed callback URLs). It refuses a revision no host has registered, and returns at once for one already promoted.apps/server/src/fleet.tsis thedist/fleet.jsentrypoint; the image build now requires it.Docs.
docs/OPERATIONS.mdgains Production: setup, deploy, rollback, restore and secret-rotation runbooks, and names the host log group. ADR-0012 gains the production topology. README, AGENTS, product, ADR-0004/0010 and the API docs now say production is written but not yet deployed.Choices worth checking
rotationinput (release / overlap / seal) names those runs<commit>-overlap-<run>and<commit>-seal-<run>. Rotation needs no new commits.What a restore can't do. Neon's branch restore does not revert Object Storage (Neon), so the runbook says which bytes a restore can't bring back. It also says that fleet rows for tasks ECS has forgotten keep holding fleet budget: the controller never treats a missing task as stopped, and nothing clears such rows yet.
Third of three stacked PRs. Based on #520 (
infra/415-cdk): the workflow deploys its stacks and reads their outputs. Closes #415.How it was verified
pnpm checkandpnpm verifypass locally; actionlint and shellcheck pass on the workflowFleet.promotecase topackages/execution/src/Fleet.test.ts: it refuses an unregistered revision, promotes once spares are warm, and returns at once on a rerunNothing has been deployed: the workflow can't run until #416's setup is done.
Release impact
Made by Claude Opus 5.5 (1M context) via Claude Code, in T3 Code.