Skip to content

feat(deploy): the cutover — deploy inactive, smoke-test, flip, retire - #472

Merged
athvin merged 1 commit into
mainfrom
bm/bluegreen-p11-cutover
Nov 5, 2026
Merged

athvin merged 1 commit into
mainfrom
bm/bluegreen-p11-cutover

Conversation

@athvin

@athvin athvin commented Nov 4, 2026

Copy link
Copy Markdown
Owner

Top of a four-PR stack, all rebased onto current main: #456 (migrate --plan) → #461 (colour dimension) → #468 (pre-upgrade hook) → this. Retarget each child to main before merging its parent — a stacked PR whose base branch is deleted on merge gets marked MERGED with a real merge commit while its code never lands (it cost #438 earlier in this stack).

The deploy becomes four phases instead of one helm upgrade, and traffic only moves after the new colour has answered through its own Services.

The namespace chart              (unchanged)
Read the live colour             from svc/er-web's selector — never guessed
Deploy the inactive colour       new digests, color.active UNCHANGED
Smoke-test the inactive colour   through the PREVIEW Services
Cut over                         one field on two Service objects
Retire the old colour            only after the cutover is verified

Four decisions worth reviewing

The live colour is read, not stored. svc/er-web's selector is the same field the cutover moves, so it cannot drift from reality the way a convention or a recorded value would. make dev-resume reads it the same way. An absent selector means first install — nothing to cut over from, so the cutover steps skip.

The live colour is pinned to the digests it is already serving during the deploy phase. Without that, the live Deployment re-renders to the new digest and restarts the pod taking traffic — the outage this whole stack exists to remove. Those digests are read off the live Deployment's own containers by container name, so the two halves cannot be transposed.

The schema gate is the hook, not a step here. #468's er-schema-migrate (weight −5) already runs er-server migrate --expect-additive, which plans first and refuses — writing nothing — if the release is breaking. Helm runs hooks before any release object is applied, so a breaking release fails with the live colour untouched. A separate preflight Job would be the same check twice. images.api/web.digest is what the hook migrates with, which is why it carries the new digests while the colour blocks pin per-Deployment.

Retiring the old colour is deliberately not coupled to the cutover. It runs only after the cutover is verified, so a failure there leaves traffic correctly on the new colour with one surplus pod — the harmless direction. Scaled to zero rather than left warm, because two serving pods doubles a namespace's steady-state cost; the Deployment is kept, so the next deploy scales it up with its image already cached. A rollback after that point needs the replica count back as well as the selector, which is why the step summary prints the command while the old pod is still there.

The smoke test hits the preview Services, and that is the point

Hitting the live ones would test what is already in production and pass for the wrong reason — the failure that would make this mechanism decorative without looking broken.

Readiness (#437) already proves er-server reached the control plane and the BFF reached er-server. This adds the one thing a probe cannot: that the answer arrives through a Service, over the network path a real request takes.

Verified on a real cluster, in throwaway namespaces

The parts most likely to be subtly wrong are the ones a render cannot check:

check result
every run: block, bash -n 12 blocks, 0 syntax errors
inline ${{ }} in any shell body none — every value arrives via env:, so nothing is interpolated into a command line
the colour read, against a live Service 'blue' → target green
digest extraction, against digest-pinned Deployments both halves → sha256:…, selected by container name
first-install branch absent Service → empty → direct path
can the smoke test fail? unreachable target → kubectl run exits 7 (curl's code propagated)
positive control reachable target → exit 0

That last pair is the one I'd want a reviewer to care about. A smoke test that cannot fail is worse than none, and the positive control is what makes the negative result mean "the target is down" rather than "DNS or the image was broken".

The escaped executor.dagKinds=lake_maintain\,lake_migrate survives in both helm invocations — checked in the rendered file rather than assumed.

Verification

  • make check green.
  • skills-check reports no generated-reference drift: the generator reads job metadata, and only steps changed.

Note on CI: GitHub is still refusing runners for this account (steps_sum=0, repo-wide — see the ci-jobs-fail-to-start-quota memory). Every gate above was run locally or against the kind cluster.

🤖 Generated with Claude Code

@athvin
athvin changed the base branch from bm/bluegreen-p10-migrate-hook to main November 5, 2026 00:15
@athvin
athvin force-pushed the bm/bluegreen-p11-cutover branch from 1062efd to 9f9f230 Compare November 5, 2026 00:19
@athvin
athvin force-pushed the bm/bluegreen-p11-cutover branch from 9f9f230 to 967d41b Compare November 5, 2026 12:11
@athvin

athvin commented Nov 5, 2026

Copy link
Copy Markdown
Owner Author

Rebased onto main now that #456, #461 and #468 have all landed — down to the single cutover commit.

One conflict, resolved by keeping both sides: #479 added a Say what was deployed step immediately before Roll the release, and this PR replaces Roll the release with the five cutover steps. The summary step is kept intact and the cutover follows it:

… Install the observability stack
   Say what was deployed          <- #479, preserved
   The namespace chart
   Read the live colour
   Deploy the inactive colour
   Smoke-test the inactive colour
   Cut over
   Retire the old colour

Recovery was a cherry-pick, not a rebase — the parents are in main as squashes, so git rebase origin/main replays them against themselves and conflicts with its own content.

Re-verified after the resolution: make check green, every run: block passes bash -n (0 syntax errors), and no inline ${{ }} in any shell body this PR adds (main's pre-existing summary step keeps its own).

The deploy becomes five phases instead of one `helm upgrade`, and traffic only
moves after the new colour has answered through its own Services.

    Say what was deployed          (#479, unchanged)
    The namespace chart
    Read the live colour           from svc/er-web's selector — never guessed
    Deploy the inactive colour     new digests, color.active UNCHANGED
    Smoke-test the inactive colour through the PREVIEW Services
    Cut over                       one field on two Service objects
    Retire the old colour          only after the cutover is verified

**The live colour is READ, not stored.** `svc/er-web`'s selector is the same
field the cutover moves, so it cannot drift from reality the way a convention
or a recorded value would. `make dev-resume` reads it the same way. An absent
selector means first install: nothing to cut over from, so the cutover steps
skip.

**The live colour is pinned to the digests it is ALREADY serving** during the
deploy phase. Without that the live Deployment re-renders to the new digest and
restarts the pod taking traffic — the outage this exists to remove. Those
digests are read off the live Deployment's own containers BY CONTAINER NAME, so
the two halves cannot be transposed.

**The schema gate is the hook, not a step here.** `er-schema-migrate` (weight
-5) already runs `er-server migrate --expect-additive`, which plans first and
refuses — writing nothing — if the release is breaking; Helm runs hooks before
any release object is applied, so a breaking release fails with the live colour
untouched. A separate preflight Job would be the same check twice.

**The smoke test hits the PREVIEW Services, and that is the point.** Hitting the
live ones would test what is already in production and pass for the wrong
reason. `charts-check.py` now refuses a chart whose previews point at the live
colour, so the two halves of that property are enforced in different places.

**Retiring the old colour is deliberately decoupled from the cutover.** It runs
only after the cutover is verified, so a failure there leaves traffic correctly
on the new colour with one surplus pod — the harmless direction. Scaled to zero
rather than left warm (two serving pods doubles a namespace's cost); the
Deployment is kept, so the next deploy scales it up with its image cached. A
rollback after that point needs the replica count back as well as the selector,
which is why the step summary prints the command while the old pod is still
there.

**`executor.dagKinds` is now ONE value in `env:`, not two literals.** This step
pair introduces a second `helm upgrade`, and #498 had just extended the
allowlist to the `run_all_*` kinds — two hardcoded copies would have drifted
the first time someone added a third kind to one of them. #498's reasoning for
which kinds are on moves up with the value rather than being left behind in the
step that carried it.

Rebuilt on main's file rather than hand-resolving a conflict, after a
cherry-pick hit two hunks: #479 added a summary step immediately before the
step this replaces, and #498 expanded the allowlist inside it. Taking either
side alone would have silently dropped one of them. Verified both survive —
the summary step, and #498's expanded list in both invocations with its
rationale.

Verified on a real cluster, in throwaway namespaces, because the parts most
likely to be subtly wrong are the ones a render cannot check:

- every `run:` block syntax-checked with `bash -n` (0 errors)
- no inline `${{ }}` in any shell body this adds — values arrive through `env:`
- the colour read, against a live Service: `'blue'` -> target `green`
- digest extraction, against digest-pinned Deployments: both halves parsed to
  `sha256:…`, selected by container NAME
- the first-install branch: absent Service -> empty -> direct path
- **and that the smoke test can FAIL.** `kubectl run` propagates the
  container's exit code: unreachable target -> exit 7, with a positive control
  against a reachable one -> exit 0. A smoke test that cannot fail is worse
  than none, and the positive control is what makes the negative result mean
  "the target is down" rather than "DNS or the image was broken".

Verified: `make check` green.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@athvin
athvin force-pushed the bm/bluegreen-p11-cutover branch from 967d41b to 9ce6a5f Compare November 5, 2026 13:11
@athvin

athvin commented Nov 5, 2026

Copy link
Copy Markdown
Owner Author

Rebuilt on main's file rather than hand-resolving, after a cherry-pick hit two hunks — and both were substantive rather than mechanical:

Taking either side alone would have silently dropped one of them: mine would have reverted #498's allowlist and lost #479's stale-image reporting.

One improvement that fell out of it. This PR introduces a second helm upgrade, so two hardcoded copies of dagKinds would have drifted the first time someone added a third kind to one of them. It is now a single DAG_KINDS value in env:, referenced by both, with #498's reasoning for which kinds are on moved up alongside the value rather than left behind in the step that carried it.

Verified both survive rather than trusting the rebuild:

DAG_KINDS: 'lake_maintain\,lake_migrate\,run_all_full\,run_all_incremental'   (x2, in env)
--set "executor.dagKinds=$DAG_KINDS"                                          (x2, both invocations)
#498's rationale kept: 1
#479's summary step kept: 1

Re-ran after the rebuild: make check green, every run: block passes bash -n (0 errors), no inline ${{ }} in any shell this PR adds.

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.

2 participants