Skip to content

ci(deploy-dev): add promote_sha + dry_run (promote a staging-verified SHA to prod) - #2416

Closed
lilyshen0722 wants to merge 1 commit into
mainfrom
sre-promote-sha-dryrun
Closed

lilyshen0722 wants to merge 1 commit into
mainfrom
sre-promote-sha-dryrun

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

What

Adds a promote_sha and dry_run path to deploy-dev.yml, additive — the existing build path is unchanged and stays the escape hatch.

promote_sha=<full sha>

Deploys a prebuilt, staging-verified SHA to prod with no docker build (retag at <sha8>). The gate refuses unless:

  • the tag has no -staging suffix — the frontend being promoted is the prod variant (deploy-staging.yml builds frontend:<sha8> prod + frontend:<sha8>-staging);
  • the SHA carries a staging-smoke=success commit status;
  • commonly-{backend,frontend,bot}:<sha8> already exist in Artifact Registry.

dry_run=true

Resolves the tag/mode, runs the gate checks, prints the plan, and stops — no build, no helm, no cluster change (target ≤4 min). The build steps, helm upgrade, and all cluster verifications are gated to build-mode / non-dry.

Adds statuses: read so the promote gate can read the staging-smoke status.

R4 — dev environment deployment-branch policy (documented, NOT applied)

docs/deployment/promote-and-branch-policy.md records the repo-settings change to make by hand at merge on Friday (after the 12:00 cut): restrict the dev environment's deployment branches to main + deploy/*. Today it has none, so any ref can deploy prod (R4). This PR does not change repo settings.

R12 hygiene

No project id / WI SA email / registry host in the diff — unchanged from deploy-dev.yml's secret-driven pattern.

Depends on deploy-staging.yml (the PR that produces the staging-smoke status + the prebuilt prod-variant images). Merges after Friday's 12:00 cut; draft until then.

Gate: Rhea.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Nju36GWpimrACHLKahbB4L

… SHA)

Additive to the existing build path. promote_sha deploys a prebuilt,
staging-verified SHA to prod with no docker build: a gate refuses unless the
tag is the prod frontend variant (no -staging suffix), the SHA carries
staging-smoke=success, and commonly-{backend,frontend,bot}:<sha8> already exist
in AR. dry_run resolves + runs the gate + prints the plan with no build/deploy
(≤4 min). Build steps + helm upgrade + verifications are gated to build mode /
non-dry. Adds statuses:read to read the staging-smoke status.

docs/deployment/promote-and-branch-policy.md documents (does NOT apply) the
Friday dev-environment deployment-branch policy (main + deploy/*).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Nju36GWpimrACHLKahbB4L

@lilyshen0722 lilyshen0722 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unasked review of 55b4d2205a5503cf2500199cca39d5760b157895 (tree 47ebb953433f3b2881eba57ca7509a2f56b46c5f) — unreviewed, base current, mergeStateStatus BLOCKED. No GATE: line; none was requested. Stamping the tree as well as the sha.

The gate is built the right way round. It fails closed: a gh api failure leaves STATE empty and the != success branch refuses, so an unreachable status API cannot be mistaken for a pass. The -staging suffix check stops the staging frontend variant reaching prod, which is the one image where the two environments differ by tag rather than by content. And dry_run gates every mutating step I can find — the four builds, the gateway probe, helm upgrade, rollout verification, the backend probe, the stranger journey and the unhealthy-workload notice — while deliberately still running the promote gate, which is what makes dry_run useful for answering "is this SHA promotable".

Finding 1 — the gate pins the images; nothing pins the chart. promote_sha is never checked out.

actions/checkout takes only submodules: recursive — no ref: — so the workspace is the dispatched ref, while --set *.image.tag points at promote_sha's images. helm upgrade then runs against k8s/helm/commonly + values.yaml + values-dev.yaml from the dispatched ref.

So promoting SHA X ships X's images under whatever chart and values main has at dispatch time. If main moved past X with a template or values change — a new env var, a changed secret ref, a replica count — prod gets a combination that was never staging-smoked, and the gate cannot see it, because every check it runs is about images. The PR's own wording is precise about what it guarantees ("never ships an unverified or staging-variant image"); the policy doc's "promoting a staging-verified SHA" reads broader than that.

workflow_dispatch can only be launched from a branch or tag, so the dispatcher has no way to align the chart with the promoted SHA by hand. The fix belongs in the workflow: ref: ${{ inputs.promote_sha || github.ref }} on the checkout. GitHub still reads the workflow definition from the dispatched ref, so only the workspace moves — the change is safe and makes the promotion whole.

Finding 2 — promotion deliberately does not advance clawdbot-gateway, and nothing says so.

I nearly filed this as an outage and it is not one, so: GATEWAY_TAG only ever adds --set agents.clawdbot.image.tag, never an enabled flag. In promote mode the gateway step is skipped, GATEWAY_ENABLED is empty, the array stays empty, and the gateway simply keeps its chart-pinned tag. It is not disabled. The inline comment — "Point the gateway at this run's tag only when this run built it" — is correct for promote mode too.

The gap is documentation with a real consequence. The gateway image is where the openclaw extension and its commonly_* tool surface live, so a promoted SHA that carries a gateway change or a submodule bump does not reach the fleet, and the promote gate checks three images rather than four, consistent with that. Neither promote-and-branch-policy.md nor the gate's error text says the gateway is out of scope for promotion. Someone shipping a tool-surface change by promotion would watch it succeed and reach nothing.

Finding 3, minor — the doc says promotion retags; it does not. promote-and-branch-policy.md says the promote path "retags the prebuilt prod images at <sha8>". There is no retag step: the gate asserts …:<sha8> already exists and helm points at that tag. The behaviour is better than the description — no registry write at all — but a reader looking for the retag will not find it.

One thing I want to flag as correct rather than as a finding, because it reads like an oversight and is not: the new dev-environment branch policy is deliberately not applied by this PR, and the doc says so plainly, with the current state ("no deployment-branch restriction, so Deploy Dev can be dispatched from any ref and ship it to prod") and the rollback. Writing the pending repo-settings change down where it is reviewable is the right call; the gap it names is the reason Finding 1 matters today.

@lilyshen0722

Copy link
Copy Markdown
Contributor Author

Closing: the prod gate on a green staging smoke landed in #2492. A no-rebuild promote path can be reopened from fresh main if we want it.

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