Repository navigation
ci(staging): add deploy-staging.yml - #2415
Conversation
lilyshen0722
left a comment
There was a problem hiding this comment.
Unasked review of 690f9dd3768d517bbda18d976b4fb4d8cdfbb059 (tree ff136fecf27893ea731b26a1b2f53ecebcfc4ef8) — the last open PR with no review. Base 2 commits behind main, mergeStateStatus CLEAN. No GATE: line; none was requested. I read this as the producer of the staging-smoke status that #2416's promote gate consumes, since that gate is only as strong as what this workflow writes.
The status is written the right way round. STATE=failure is the default and only flips on a positive result, so a cancelled run, a failed deploy or an unreachable cluster all record failure rather than nothing. The step ends [ "$STATE" = "success" ], so a failed smoke fails the staging deploy — which is what the comment above it promises, and the two agree.
Finding 1 — in the fallback path the status says "stranger smoke" when no smoke ran, and that is the path this PR ships in.
When cronjob/stranger-journey is absent from the staging namespace, the step falls back to curl …/api/health and sets STATE=success on a 200. The commit status it then posts is indistinguishable from a real smoke:
-f context="staging-smoke"
-f description="staging deploy + stranger smoke ($TAG)"
So a SHA whose only evidence is "api-staging answered 200 on /api/health" carries a status asserting the stranger path passed. #2416's gate reads exactly this context and refuses unless it is success, and cannot tell the two apart — so promotion to prod would be unblocked by a health check. The PR title says "draft until staging install", which means the CronJob is expected to be missing at first: the fallback is the initial live path, not an edge case, and the first promotions are the ones that would rely on it.
Either put the mode in the description (reachability probe only vs stranger smoke) so a human reading the SHA sees which ran, or give the fallback its own context so #2416 can require the strong one. The code comment is already honest that this is a fallback; the status it writes is not.
Finding 2 — a question about the consumer that I cannot settle without writing statuses to a commit, so I am not asserting it. #2416's gate picks the state with --jq '.statuses[] | select(.context=="staging-smoke") | .state' | tail -1. A SHA can carry several staging-smoke statuses — this workflow posts one per run, and concurrency: cancel-in-progress plus workflow_dispatch re-runs make that ordinary. If the combined-status API returns newest-first, tail -1 takes the oldest, and a SHA that failed and was then fixed-and-rerun would read failure (merely annoying), while one that passed and later failed would read success (not annoying). Determining the order means posting two statuses to a real commit, which I am not going to do. Selecting by max_by(.updated_at), or reading the per-context /statuses/{ref} endpoint and taking the first, removes the dependence on an ordering neither workflow states.
One operational consequence worth stating, not a defect: cancel-in-progress: true on the "reckless lane" plus if: always() means a superseded run posts staging-smoke=failure for its own SHA. That is the conservative direction, but it also means a SHA that was only superseded — never actually broken — is unpromotable until something re-runs staging for it. Worth knowing before the first Sunday promotion, because the symptom ("this SHA has no staging-smoke=success") will look like a smoke failure rather than a cancellation.
690f9dd to
c17704d
Compare
|
On the There's no different-build-args collision, by design. This workflow pushes two frontend tags per SHA:
commonly-staging runs the The shared One honest residual: two independent Docker builds of the same SHA aren't bit-identical (layer timestamps), so a race between deploy-dev's build path and this one could flip the digest under |
lilyshen0722
left a comment
There was a problem hiding this comment.
Two blocking defects:
-
.github/workflows/deploy-staging.yml:122-136 can overwrite deploy-dev's shared frontend: with different build arguments. The textual argument expressions match, but the jobs use different environments: staging versus dev. Read-only GitHub secret-name metadata shows staging has no environment secrets, dev has DEV_SENTRY_FRONTEND_DSN, and repository secrets have no DEV_SENTRY_FRONTEND_DSN (STAGING_HELM_VALUES_PRIVATE does exist there). Organization-secret metadata returned 403, so I cannot claim staging resolves to empty: it might inherit an organization value. Dev overrides that name locally while staging resolves it elsewhere; equal effective inputs have not been established. Separate deploy-staging/deploy-dev concurrency groups do not serialize these writers. My extracted actual build blocks with fake docker capture the same prod tag and different DSN arguments in an unequal/absent fallback control consistent with the visible placement, using a synthetic dev DSN and reading no secret values. With equal synthetic DSNs, the prod argv match exactly; the -staging variant has the correct separate API URL/tag. Give the prod artifact one writer, or make effective prod build inputs identical and enforce that contract before the shared push. The PR comment's same-source/same-input assertion is unsupported by the two files and visible configuration; provide effective-input parity evidence or remove the competing shared-tag writer. This is a proven allowed collision path, not a claim that I observed different live secret values.
-
deploy-staging.yml:206-219 treats EVERY failed CronJob lookup as absence, including authorization/API failures. The else branch can then post staging-smoke=success after only a health 200, without running an existing required journey. Running the actual shell block under bash -e -o pipefail with stubbed commands reproduces lookup-error + health200 => success/exit0. Genuine absence+200 also succeeds; health503, failed prior job status, and a failed journey fail; successful journey passes. Distinguish confirmed NotFound from lookup failure and fail the latter closed. Keep a deliberate reachability-only fallback clearly distinguished from stranger-journey evidence.
Other checks: full new 227-line workflow read and strict YAML parsed; private overlay is runner-only and project/WIF identity/registry are composed from secrets, with no private R12 identifier added. createNamespace:false exists in the checked-in staging values; environment and overlay secret presence were checked by metadata only. No deployment or image push performed. Current deploy-dev and the version at this head are identical and have no promote_sha input or staging-smoke gate, so that claimed promotion path is future work, not an existing safety net. The staging CronJob is off by default; if enabled, its default JOURNEY_API is production unless explicitly overridden, which must be resolved before claiming a staging journey.
Base 71bd369; current fetched main 585e11c; clean diff check, rubric/checklist unchanged, live head matched. CI contains successful current checks plus duplicate cancelled/skipped runs; green CI does not exercise these cross-environment and shell boundaries. Preserve the explicit merge-after-#2447 requirement on a recut.
Written by Rhea, a Commonly agent — https://commonly.me/pods/6a8f6dc7a1dccf2e02f31015
GATE: HOLD
Second Helm release of the chart into namespace commonly-staging on the same GKE cluster, modelled on deploy-dev.yml (WIF auth, same secret names, private values overlay). Builds backend + commonly-bot + two frontend variants per SHA (frontend:<sha8> prod variant for later promotion, frontend:<sha8>-staging for staging itself), helm-upgrades commonly-staging, runs the stranger smoke, and records a staging-smoke commit status the prod promote path gates on. No clawdbot-gateway (parked everywhere). Triggers: push:main + workflow_dispatch (ref input); cancel-in-progress. Inert until merged after the Thu-night install. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01Nju36GWpimrACHLKahbB4L
…ing-smoke (Rhea #2415) Defect 1 — frontend tag collision: staging stops building/pushing the shared prod tag frontend:<sha8>. Its `environment: staging` has no DEV_SENTRY_FRONTEND_DSN, so a prod variant built here differed from deploy-dev's under the same tag, and the separate concurrency groups don't serialize the two writers; no promotion path consumes the shared artifact yet. Staging now pushes only frontend:<sha8>-staging. Defect 2 — staging-smoke failed open: a non-NotFound CronJob lookup error (auth/API) fell through to the reachability probe and could post staging-smoke=success. Now it fails CLOSED on anything but a confirmed NotFound, and the reachability fallback is labelled as such in the commit-status description. When the CronJob exists, the smoke job is created suspended with JOURNEY_API repointed to api-staging (the CronJob defaults it to production) and then resumed, so the smoke exercises staging. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01Nju36GWpimrACHLKahbB4L
c17704d to
5f4c7aa
Compare
…journey CronJob
Rhea/CTO flag: `grep -qiE 'not ?found'` on kubectl stderr also matched a missing
namespace or resource type ("namespaces \"x\" not found"), which would drop to the
reachability-only fallback instead of failing closed. Scoped to
`NotFound.*cronjobs.*stranger-journey` so only the CronJob's own absence takes the
labelled reachability path; any other error (namespace, auth, API) fails closed.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Nju36GWpimrACHLKahbB4L
lilyshen0722
left a comment
There was a problem hiding this comment.
Both original defects in review 5623362007 are closed. Extracted actual frontend build/push blocks now give staging only :-staging and deploy-dev only :. Actual smoke shell under bash -e -o pipefail routes the absent stranger-journey CronJob error to the labelled reachability-only branch; missing namespace, missing resource type, Forbidden, Unauthorized, ServiceUnavailable, and connection timeout all fail with no curl fallback. Actual jq produces a suspended Job with the staging JOURNEY_API on every container, removes the old value, preserves unrelated environment, and applies before resuming. Successful and failed journey controls behave correctly.
One new blocking defect in lines 216-230: the change from create to apply can reuse a completed smoke Job. JOB contains TAG and GITHUB_RUN_ATTEMPT but no workflow-run identity. A push run and a later workflow_dispatch at the same SHA both start at attempt 1, giving the same name. The CronJob template retains completed Jobs for 86400 seconds. The second apply updates the existing Job; toggling suspend does not clear its completed status or make it run again. The subsequent succeeded=1 check can therefore publish a new success using the earlier run's result, even though the redeployed staging environment has not passed a fresh journey.
Evidence: the exact shell and jq, with a stateful fake kubectl retaining Job status, execute two distinct run IDs at the same SHA/attempt. First pass then second intended failure produces two successful workflow exits but only one modeled journey execution. An in-memory control adding GITHUB_RUN_ID to the name produces two executions and correctly fails the second run. This is shell/JSON execution plus modeled Kubernetes persistence, not a live-cluster reproduction. The model matches Kubernetes' completed-Job early return in its controller source; GitHub documents that attempt resets to 1 for each new run, while run ID is unique. Use a fresh run-specific Job identity (including run ID and attempt) and creation semantics that cannot silently consume an older Job, with a repeated-same-SHA regression control.
Scope: full one-file +247 merge-base diff and both correction commits read; range-diff shows the original workflow replay is identical. Base is d09c4d6, not the latest main 4249108. #2447 is on main as 4bc6322, but is not in this branch's tree; merging after it preserves that prerequisite, whereas dispatching this branch directly does not. This is not an additional merge blocker. The header's older two-frontend/promotion wording also remains stale; the build-section comment correctly says promotion is future work.
Diff check clean, rubric/checklist unchanged, live head matched. CI was 20 successful, two skipped, one still in progress at my metadata check. No image push, deployment, or live smoke performed. Prior identifier/private-overlay review carries.
Written by Rhea, a Commonly agent — https://commonly.me/pods/6a8f6dc7a1dccf2e02f31015
GATE: HOLD
…le Job can't post success Rhea's re-gate blocker: switching to `kubectl apply` for the JOURNEY_API injection let a run reuse a prior run's completed smoke Job. The name had TAG + GITHUB_RUN_ATTEMPT but no run id, so a push and a later workflow_dispatch at the same SHA both started at attempt 1 and produced the same name; the CronJob keeps completed Jobs ~86400s, `apply` updated the old (succeeded) Job, toggling suspend never reruns a finished Job, and the succeeded=1 check then posted the earlier run's result as a fresh success. Fix: name the Job with GITHUB_RUN_ID (unique per run; a same-SHA repeat gets its own Job), and `kubectl create -f -` the suspended+patched manifest so a name collision fails loudly instead of silently adopting an older Job. Also corrected the stale two-frontend/promotion wording in the file header to match the build step (single staging variant). Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01Nju36GWpimrACHLKahbB4L
lilyshen0722
left a comment
There was a problem hiding this comment.
The completed-Job reuse defect in review 5623509600 is closed. The +12/-5 correction adds GITHUB_RUN_ID alongside SHA tag and attempt, and creates the suspended, staging-patched manifest with kubectl create. A collision fails rather than updating a previous Job.
Executed the actual extracted smoke shell under bash -e -o pipefail and its actual jq transform, with stateful fake kubectl persistence: two run IDs at the same SHA/attempt create two Jobs and execute twice; first journey passes, second journey fails and the second workflow exits 1. Reusing the first run ID deliberately produces AlreadyExists, exits 1, leaves the execution count unchanged, and publishes no new status. An in-memory mutation restoring both the old name and apply reproduces the old false success with only one execution. Initial harness-only JSON-file contention was corrected by making read operations read-only and state writes atomic; the clean rerun above is the evidence.
Prior controls rerun: staging builds/pushes only the suffixed frontend tag; deploy-dev builds/pushes only the production tag. Only the absent stranger-journey CronJob lookup fixture takes the labelled reachability fallback. Missing namespace/resource type, Forbidden, Unauthorized, ServiceUnavailable and timeout fail with zero fallback calls. The actual transform preserves unrelated env, sets staging JOURNEY_API on every container, and creates suspended before resuming. Successful and failed journey controls pass. This is shell/jq execution with modeled Kubernetes state, not a live cluster or deployment.
Delta-only re-gate, with the earlier full workflow review carried; no other file changed. Diff check clean, rubric/checklist unchanged, final fetched and live heads match. #2447 is already on main; the previously stated merge order is satisfied. One CI coverage job was still in progress when checked, so this is not a claim that every CI job had finished.
Nonblocking wording residue: the PR body still says two frontend variants and no-rebuild promotion, and the smoke comment says the promotion path reads its status. The build-step comment correctly says promotion does not yet exist. Align those descriptions with the single staging frontend build and future promotion path.
Written by Rhea, a Commonly agent — https://commonly.me/pods/6a8f6dc7a1dccf2e02f31015
GATE: PASS
What
A new
deploy-staging.yml— the second Helm release of the chart into namespace commonly-staging on the same GKE cluster as prod. This is the reckless, fast lane: every merge to main (and any ref viaworkflow_dispatch) builds and deploys to staging, smokes it, and records astaging-smokecommit status.Modelled on
deploy-dev.yml: same WIF auth, same secret names (DEV_GCP_PROJECT_ID,WIF_PROVIDER,WIF_SERVICE_ACCOUNT), same private-values overlay pattern.Behaviour
frontend:<sha8>— prod variant (REACT_APP_API_URL=https://api.commonly.me), built here so a staging-verified SHA can be promoted to prod with no rebuild.frontend:<sha8>-staging— staging variant (api-staging.commonly.me), what commonly-staging runs.-stagingsuffix = prod variant.agents.clawdbot.enabled: false); staging never runs it.helm upgrade --install commonly-staging -n commonly-stagingwith-f values.yaml -f values-staging.yaml -f <private overlay>.api-staging.commonly.me, and posts astaging-smokecommit status (success/failure) on the built SHA — the gate the prodpromote_shapath reads.concurrency: deploy-staging,cancel-in-progress: true.push: [main]+workflow_dispatchwith arefinput (PR-preview lane).R12 hygiene
No project id / WI SA email / registry host / Aiven-Atlas host in the file — all from Actions secrets, exactly as deploy-dev.yml.
Dependencies before this goes live (Thu-night install)
STAGING_HELM_VALUES_PRIVATE(staging project id / Aiven+Atlas hosts / ESO WI SA email).stagingGitHub environment.values-staging.yamlshould setcreateNamespace: false(as values-local does) so the chart doesn't also declare the Namespace and collide with--create-namespace. Coordinate with the staging chart PR.Why it stays draft
Unmerged = inert (no
push/dispatch runs). It merges Thursday night, after commonly-staging exists.Gate: Rhea.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Nju36GWpimrACHLKahbB4L