Skip to content

ci(bluegreen): run the two-colour cutover acceptance criterion in ci (#656) - #811

Merged
athvin merged 3 commits into
mainfrom
issue/656-bluegreen-cutover
Nov 7, 2026
Merged

athvin merged 3 commits into
mainfrom
issue/656-bluegreen-cutover

Conversation

@athvin

@athvin athvin commented Nov 7, 2026 •

Copy link
Copy Markdown
Owner

Closes #656

Post-merge is part of this pull request. The ledger below records whether
the follow-up work actually happened. /land-pr closes it.

What

Runs #656's criteria 1 and 2 against ci on er-dev for the first time, and
leaves scripts/ci/bluegreen-acceptance.sh behind so the criterion is
re-runnable after any change to the deploy path.

Criteria 3 and 4 are not in this PR — they need a release through
images.yml, which only runs on push: branches: [main]. Split to #813
with the reasoning.

Why

The blue/green stack shipped across 14 PRs, each verified by content on main,
and the end-to-end criterion the plan specified was never executed. "Zero-downtime
cutover" was a design claim rather than a measurement.

Proof

Ran the script against the live namespace, both directions, with both colours
pinned to identical digests so the only variable is the selector move:

cutover requests non-2xx helm upgrade
blue → green 116 0 35s
green → blue 98 0 29s

scripts-home-check ok (91 scripts). The namespace was left exactly as found:
blue live, web-api-green at replicas=0.

Risk & rollback

Risk: the script mutates a live namespace — it scales the inactive colour up
and moves color.active. Confined to ci, which CI owns, and it refuses to
report a measurement if another actor moved the release mid-window.

Rollback: git revert <merge-sha> removes the script; it changes no
deployed behaviour. The namespace needed nothing undone — the exercise restored
it to blue-live/green-retired, as found.

Post-merge note: ci is now green-live/blue-retired. Not a remnant of this —
the deploy run on 70f31c54 (#756's merge, 21:41Z) performed its own cutover
and took the Helm release 129 → 131. My measurement ended at 129 and its
concurrency guard confirmed revisions 125 → 127 → 129 were all mine, which is
exactly the case that guard exists to distinguish.

Post-merge ledger

Closed by: agent · session 77317896-77a9-4b7f-966e-2d180637edf7 on brians-MacBook-Pro · 2026-11-07T22:10:20Z

  • main is green with this change on it — the merge SHA, and the run
    that proves it. A later head SHA with this commit as an ancestor counts;
    a cancelled run with zero jobs does not: e730e6e6 — rust, infra, frontend, devcontainer all success on that SHA.
  • images built, or correctly never ran because nothing that goes into
    an image changed: n/a — correctly never ran. The diff is .claude/skills/…/coverage.md + scripts/ci/bluegreen-acceptance.sh; no image input changed, and images is absent from the merge SHA's run list rather than having been cancelled.
  • deploy converged — proved by a line the running process emitted, not
    by the image digest and not by the workflow conclusion: n/a — no deploy exists to converge. deploy.yml fires on workflow_run after images, which never ran.
  • the push-only surface no pull request can pre-test (deploy, drift,
    kind's nightly leg) is green, or knowingly red for a reason that is not
    this change: deploy n/a as above. drift and kind are nightly, not per-merge: both last concluded success (59d3f60e, 2026-11-07 06:01Z and 06:44Z). Not green on this SHA, because neither runs on one — stated rather than ticked as if it were.
  • the board card reached Done through the automation rather than by
    hand, and the issue closed: Blue/green: run a real two-colour cutover in the ci namespace (the acceptance criterion never exercised) #656 is CLOSED / COMPLETED and its card reads Done, both via the automation — no hand edit.
  • follow-ups are open for everything deferred here — numbers: Blue/green criteria 3 and 4: the expand case, and the preflight refusal (both need a release on main) #813 (criteria 3 and 4).
  • what was learned is written down where the next session will find it
    (a skill, a reference, memory) — or nothing new was learned: the bluegreen-program memory now carries the measured table, the three harness traps (service ports 3000/8000 not 80; /api/healthz; date +%3N exiting 0 on macOS), the rollback-mechanism correction, and the concurrency-guard rule. The re-runnable form is scripts/ci/bluegreen-acceptance.sh in the tree.

Specific to this change

Context — plan, discoveries, measurements, files

Plan

  • 1. Survey the live namespace — which colour is live, are both digests the
    same, is there quota headroom.
  • 2. Write the exercise as a script rather than a runbook, with a
    concurrency guard against deploy.yml.
  • 3. Criterion 1 — zero-downtime, measured, through the live Services.
  • 4. Criterion 2 — rollback, measured the same way.
  • 5. Restore the steady state and check the issue's two stated constraints.
  • 6. Criteria 3 and 4 — split to Blue/green criteria 3 and 4: the expand case, and the preflight refusal (both need a release on main) #813; neither is reachable from a branch.

Discoveries

Three bugs in my own harness, each of which would have produced a confident
wrong answer:

  • svc/er-web listens on 3000, not 80. Port-forwarding 80 returns 000 for
    every request — indistinguishable from a total outage, and it cost a diagnosis
    pass before I noticed the service had healthy endpoints all along.
  • the frontend health route is /api/healthz, not /api/health.
  • date +%3N is GNU-only. On macOS it emits a literal .3N and exits 0, so
    a || fallback never fires and every timestamp is silently garbage.

The issue's rollback claim is right in magnitude but not in mechanism. It
says "the old colour never stopped running, so this should be seconds". That
holds only between cutover and retire — deploy-retire-colour.sh scales the old
colour to zero afterwards, which is the steady state I found the namespace in
(only blue running). So a real rollback is a scale-up, not a selector move.
Measured anyway: ready in 7s from replicas=0, because that script scales
rather than deletes and the image stays cached on the node. Both paths are
seconds; the reasons differ.

Criteria 3 and 4 need a merge to main, not a branch. images.yml is
push: branches: [main] with a paths: filter, and deploy.yml fires on
workflow_run after it. There is no branch path to a ci deploy, so neither
remaining criterion can be exercised from this PR.

make check cannot pre-empt the deploy preflight, which is the point of it.
The preflight is the er-schema-migrate hook running
er-server migrate --expect-additive, and it compares the compiled catalog
against a live store. make check has no Postgres (that is make check-e2e),
so a retype is self-consistent in the catalog and passes the PR gate — the
refusal can only happen at deploy. That makes criterion 4 genuinely reachable,
and also disruptive: it needs a deliberately breaking schema change on main,
which leaves the deploy path refusing for everyone until reverted.

Measurements

Every number with the command that produced it.

Cutover, criterion 1 — bash scripts/ci/bluegreen-acceptance.sh:

live=blue target=green  helm revision=125
image digests across colours: same
helm upgrade returned 0 after 35s
svc/er-web now selects: green
helm revision: 125 -> 127 (expected +2 from this script)
requests: 116   non-2xx/3xx: 0
  58 web/login 200
  58 api/healthz 200

Rollback, criterion 2 — the same script, run again:

helm upgrade returned 0 after 29s
svc/er-web now selects: blue
helm revision: 127 -> 129 (expected +2 from this script)
requests: 98   non-2xx/3xx: 0

Post-retire rollback cost — kubectl scale deploy/web-api-green --replicas=1
then rollout status: 7s to ready from zero.

Aurora (the issue's first stated constraint: two colours double connection
establishment against an instance that may be at 0 ACU) —
aws cloudwatch get-metric-statistics --namespace AWS/RDS:
DatabaseConnections 7 → 9 across the exercise;
ServerlessDatabaseCapacity never left 0.5 ACU. The second colour costs ~2
connections. Immaterial at this size, and worth re-checking at load.

Namespace quota (the issue's second constraint: limits.cpu 40, cutover ~5)
— kubectl get resourcequota: 2500m used of 40 before the exercise. Ample.

Files

  • scripts/ci/bluegreen-acceptance.sh — new; the whole diff.

Nothing else changed. The deploy scripts it drives
(deploy-read-colour.sh, deploy-inactive-colour.sh, deploy-cutover.sh,
deploy-retire-colour.sh) were already correct and are untouched.

bmoore813 and others added 2 commits November 7, 2026 16:47
#656's criteria 1 and 2, run against the `ci` namespace on `er-dev` for the
first time. The blue/green stack shipped across 14 PRs each verified by content
on `main`; "zero-downtime cutover" was a design claim until now because running
the criterion by hand is a dozen commands with a timing-sensitive loop in the
middle — the shape of thing that stays un-run.

MEASURED, both directions, with both colours pinned to identical digests so the
only variable is the selector move:

  blue  -> green   116 requests, 0 non-2xx   (helm upgrade 35s)
  green -> blue     98 requests, 0 non-2xx   (helm upgrade 29s)

The loop covers a document route (er-web /login) and the API (er-api /healthz),
because the issue's criterion distinguishes them. It deliberately does NOT
request `/_next/static/<build-id>/…`: a 404 there after a flip is the known
residual risk D-BLUEGREEN accepts, and counting it would fail a cutover that
worked.

Three bugs found while writing it, each of which would have produced a
confident wrong answer:

- `svc/er-web` listens on 3000, not 80. Port-forwarding 80 returns 000 for
  every request, which is indistinguishable from a total outage.
- the frontend health route is `/api/healthz`, not `/api/health`.
- `date +%3N` is GNU-only; on macOS it emits a literal `.3N` and EXITS 0, so a
  `|| fallback` never fires and every timestamp is silently garbage.

The concurrency guard is load-bearing rather than defensive: deploy.yml runs its
own three-phase cutover against this namespace on every qualifying merge, so the
script asserts the helm revision advanced by exactly its own two upgrades and
aborts otherwise. A number produced while two actors moved the colour is not a
measurement.

Also corrects the issue's rollback claim by measuring it. The asymmetry it
describes is real — pre-retire rollback is a selector move, post-retire needs the
replica count back — but both are seconds: a scale-up from zero reached ready in
7s, because deploy-retire-colour.sh scales rather than deletes and the image
stays cached on the node. That is the reason the script leaves both colours up.

Aurora, the issue's other stated constraint: DatabaseConnections went 7 -> 9
across the exercise and ServerlessDatabaseCapacity never moved off 0.5 ACU. The
second colour costs ~2 connections, which is immaterial at this size.

Namespace left exactly as found: blue live, green at replicas=0.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@athvin
athvin force-pushed the issue/656-bluegreen-cutover branch from 2e08df9 to 862cdaf Compare November 7, 2026 21:47
`infra-platform/references/coverage.md` carries a generated table of which
scripts reference each path under infra/k8s, and bluegreen-acceptance.sh drives
`helm upgrade` against infra/k8s/charts/er-platform — so it belongs in the
`charts` row. Regenerated, not hand-edited.

The gate was right and the drift was mine: `agent skills (lint + drift)` failed
on the PR, and main was green on the two commits before my rebase base, so this
was never a pre-existing break.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@athvin
athvin merged commit e730e6e into main Nov 7, 2026
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.

Blue/green: run a real two-colour cutover in the ci namespace (the acceptance criterion never exercised)

2 participants