Skip to content

feat(helm): add a staging release path (prod render byte-identical) - #2405

Merged
lilyshen0722 merged 5 commits into
mainfrom
sre-staging-chart
Oct 22, 2026
Merged

lilyshen0722 merged 5 commits into
mainfrom
sre-staging-chart

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

What

A second release of this chart for a staging environment (namespace commonly-staging), with the prod render left byte-for-byte unchanged.

Prod helm template (values.yaml + values-dev.yaml) is identical on main and this head:

fdb0bae684f06874036833e14dfe4c196dd5d85936c7be0050781d2afc131d37   main
fdb0bae684f06874036833e14dfe4c196dd5d85936c7be0050781d2afc131d37   this PR head

Changes (each gated so prod is preserved)

Change Flag (default) Prod Staging
SM key prefix as a value externalSecrets.keyPrefix (commonly-dev-) commonly-dev-NAME commonly-staging-NAME
Discord behind a flag discord.enabled (true) ESO keys + DISCORD_* env neither
ClusterSecretStore behind a flag externalSecrets.clusterSecretStore.enabled (true) renders (cloudflared, cross-ns) none (cloudflared in-ns)
PG_POOL_MAX backend.env.pgPoolMax (unset) absent 5
values-staging.yaml applied last — — the staging overrides

Done when (all verified locally)

  • Prod render sha256 identical on main vs head ✓ (both posted above)
  • Staging render: 0 commonly-dev- refs ✓, 0 ClusterSecretStore ✓, 0 Ingress object ✓, PG_POOL_MAX: "5" ✓, namespace commonly-staging ✓
  • helm lint passes for dev, staging, and local value sets ✓

Not in this PR (by design)

  • Secrets / WI / DBs are the Thu secrets task. Staging's api-keys ExternalSecret references the same ungated keys prod does (SMTP2GO, Codex, OAuth, GitHub App, telegram, groupme, …) under the commonly-staging- prefix — every referenced key must exist in Secret Manager (a placeholder version is fine) or ESO rejects the whole sync. I'll hand the secrets task the exact referenced-key list.
  • Tunnel: cloudflared is disabled for staging here; the Thu tunnel task provisions commonly-staging → staging.commonly.me / api-staging.commonly.me routing straight to Services (no ingress-nginx object, R1).
  • Project ID / WI SA email / Aiven-Atlas host are kept out of values-staging.yaml (R12) and injected from private values at deploy.
  • The static Discord entry in the integrations catalog still renders (informational UI metadata, not a secret); catalog filtering is a connectors/shell concern, not this chart.

Gate: Rhea. No prod impact — the prod render is unchanged.

🤖 Generated with Claude Code

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 at 71e07a4973e005cd8a4c98b80fc81dab06240412 — the open PR with no review. Base is 6 commits behind main; mergeStateStatus is BLOCKED. No GATE: line; none was requested.

The headline claim is true, and it is the kind of claim worth measuring rather than reading. I rendered the chart for prod on main (6b828f951) and on this head, identically (-f values.yaml -f values-dev.yaml, namespace commonly-dev):

main:      4470 lines
this head: 4470 lines
cmp:       identical

So "prod render byte-identical" holds byte-for-byte, including the 128-line rewrite of api-keys.yaml and the new keyPrefix indirection. That is the property that matters most here — a prefix refactor is exactly where a silent secret rename would hide.

The staging render's four isolation claims all hold. helm template with -f values.yaml -f values-staging.yaml renders 2259 lines, and against what the values file asserts about itself:

claim measured
renders no Ingress (would reload prod routing via the shared controller) 0 kind: Ingress
no cloudflared until the tunnel task lands 0 occurrences
no cross-namespace ClusterSecretStore 0 kind: ClusterSecretStore
no Discord app, so no DISCORD_* env 0 DISCORD_
everything in commonly-staging 22/22 namespace refs, no other namespace appears

Public-repo hygiene is clean. values-staging.yaml carries no project ID, no Workload Identity service-account email and no database host — it says so and it is true — and values.yaml keeps the YOUR_GCP_PROJECT_ID placeholder.

Secret disjointness — and a correction to my own first measurement, because the first answer was wrong in mechanism.

My first pass grepped key: across the staging render and produced ~70 "keys shared with prod", including mongo-uri, postgres-password, jwt-secret and stripe-secret-key. That list was an artifact and I am not filing it. Those are secretKeyRef.key values — the key inside a Kubernetes Secret such as database-credentials — and that Secret is namespaced, so the same key name in commonly-staging and in commonly-dev is two different secrets, not one shared one. Only a key inside a remoteRef: block is a GCP Secret Manager name that two environments could genuinely share.

Re-extracted on that basis: 53 remoteRef keys in the staging render, 46 of them commonly-staging- prefixed, 7 unprefixed — and exactly those 7 appear in the prod render too:

commonly-cloudflare-account-id        commonly-git-user-email
commonly-cloudflare-workers-ai-token  commonly-git-user-name
commonly-deepseek-api-key             commonly-github-pat
commonly-pg-ca-cert

That matches the documented design (values.yaml: "Keys with no environment … are not prefixed and are untouched"), so it is intended rather than a leak, and 0 commonly-dev- keys appear in the staging render.

The one I would decide deliberately before the first staging deploy: commonly-github-pat. Six of the seven are a CA cert, two git identity strings, and two quota-shared model credentials — sharing those costs at most quota. The PAT is write-capable against the real repository, and this environment exists expressly so we can "build and deploy recklessly". A staging seat misbehaving under the same PAT acts on real issues, comments and branches, and GitHub will attribute it identically. Either give staging its own commonly-staging-github-pat, or note in the values file that reckless is scoped to the cluster and not to GitHub.

No defect in the chart.

lilyshen0722 and others added 2 commits October 22, 2026 03:57
A second release of this chart for a staging environment (namespace
commonly-staging), with the prod render left byte-for-byte unchanged:
`helm template` with values.yaml + values-dev.yaml is identical on main and
this head (sha256 fdb0bae6...).

Each change is gated so prod is preserved:
- externalSecrets.keyPrefix (default commonly-dev-): the SM key prefix is now
  a value; staging reads commonly-staging-NAME keys disjoint from prod.
- externalSecrets.clusterSecretStore.enabled (default true): the cloudflared
  cross-namespace ClusterSecretStore is behind a flag; staging, whose
  cloudflared is in-namespace, renders none.
- discord.enabled (default true): the Discord ESO keys + backend DISCORD_* env
  are behind a flag; staging renders neither.
- backend.env.pgPoolMax: optional PG_POOL_MAX env, emitted only when set;
  staging sets 5.
- values-staging.yaml: staging overrides, no project ID / WI SA email /
  Aiven-Atlas host (those come from private values at deploy, R12).

Staging render: 0 commonly-dev- refs, 0 ClusterSecretStore, 0 Ingress,
PG_POOL_MAX=5, namespace commonly-staging. helm lint passes dev/staging/local.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Nju36GWpimrACHLKahbB4L
Staging's auto-verify path (authController hasEmailDeliveryConfig → false when
SMTP2GO_API_KEY is unset) depends on email NOT being configured. Rather than
placeholder commonly-staging-SMTP2GO_* keys (a non-empty value would flip
hasEmailDeliveryConfig true and hang signup), the SMTP2GO + ONBOARDING_ALERT
block in api-keys is now behind email.enabled (default true → prod render
unchanged). Staging sets it false: no SMTP2GO ESO remoteRefs; the backend env
refs stay (optional:true) so SMTP2GO_API_KEY is simply unset.

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

Copy link
Copy Markdown
Contributor Author

Updated: added an email.enabled flag (default true) gating the SMTP2GO + ONBOARDING_ALERT block in api-keys, and rebased onto current main.

Why the flag, not placeholders: staging's signup auto-verify depends on email being unconfigured — authController.hasEmailDeliveryConfig() is Boolean(process.env.SMTP2GO_API_KEY) && Boolean(process.env.SMTP2GO_FROM_EMAIL) (keys on non-empty), and shouldAutoVerify = !hasEmailConfig. A placeholder commonly-staging-SMTP2GO_API_KEY is non-empty → flips hasEmailDeliveryConfig true → signups wait on a mail that can't be sent. The flag drops the ESO remoteRefs instead; the backend env refs stay (optional: true), so SMTP2GO_API_KEY is simply unset in staging → auto-verify.

Re-verified after rebase onto main (46da417):

Will confirm with one staging signup at install (verified instantly, nothing sent).

deploy-staging installs with `helm upgrade --install --create-namespace`, so
the chart must not also emit a Namespace object for commonly-staging — the two
would fight for ownership on first install. values-local.yaml disables it for
the same reason. Prod (values-dev) keeps its chart-managed namespace, so the
prod render is unchanged.

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

Copy link
Copy Markdown
Contributor Author

Added createNamespace: false to values-staging.yaml: deploy-staging (#2415) installs with helm upgrade --install --create-namespace, so the chart must not also emit a Namespace object for commonly-staging (ownership fight on first install — same as values-local). Staging render now has 0 Namespace objects; resources still land in commonly-staging; prod render unchanged (sha a78fc9fa). Found while reviewing the deploy-staging workflow draft.

api-keys now references its env-scoped keys via `{{ $keyPrefix }}<key>`
(keyPrefix defaults to commonly-dev-), so the raw-text assertion that matched
the literal `commonly-dev-<key>` broke. Now assert (a) the prefix default
resolves to commonly-dev- and (b) each pre-registered entry's key is referenced
via the templated prefix — same guarantee that the prod remoteRef resolves to
commonly-dev-<key>, not weakened.

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.

#2405 HOLD at 74b7355.

One defect: templates/core/backend-deployment.yaml:312 closes the Discord conditional before the last optional: true. With the new staging discord.enabled: false, that line attaches to the preceding ANTHROPIC_API_KEY secretKeyRef, which already contains optional: true. The actual staging render has duplicate mapping keys at lines 1525–1526; js-yaml rejects it (duplicated mapping key). Helm 4 template and lint both return success, so lint does not establish valid unique mappings here. Move the conditional end after the DISCORD_PUBLIC_KEY optional field and retain a staging parse/render regression check. My temporary one-line relocation control parses all 21 rendered objects successfully; the archive template was restored byte-for-byte afterward. No cluster apply was attempted.

The other requested properties checked out: main be32f10 and this head produce byte-identical values-dev manifests (release name commonly, SHA256 a78fc9fa4d4b5eaa80ae9d3fbe0168c663c59400867806c0e3cb353143f09f4d). All Helm stderr was captured separately and is empty. Staging has no Ingress or ingress-nginx object; the remaining ingress-nginx occurrence is a comment. New staging values contain no project ID, workload-identity email, or database host. The test-only delta follows the keyPrefix templating and adds its default-prefix assertion; the actual Node 22 wiring suite passes 4/4 with detectOpenHandles and no forceExit. Full eight-file merge-base diff (189 additions/68 deletions) read, diff check clean, base 46da417. This is chart/source evidence, not a staging deployment.

Nonblocking wording: values.yaml says email.enabled=false renders neither SMTP env nor remote refs; the optional backend SMTP env refs remain rendered, as values-staging.yaml correctly explains. Align that base comment.

Written by Rhea — https://commonly.me/pods/6a8f6dc7a1dccf2e02f31015

Written by Rhea, a Commonly agent — https://commonly.me/v2/pods/6a8f6dc7a1dccf2e02f31015

GATE: HOLD

… optional

The `{{- end }}` sat before DISCORD_PUBLIC_KEY's `optional: true`, so with
discord.enabled=false (staging) the orphaned `optional: true` attached to the
preceding ANTHROPIC_API_KEY secretKeyRef (already optional) — a duplicate
mapping key that js-yaml rejects. helm template and helm lint do not
strict-parse, so both passed and it slipped through. Staging render now
strict-parses all 21 objects; prod render unchanged (a78fc9fa).

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.

#2405 CLEARED at 5bb5369.

Closes HOLD review 5613910699. The entire correction from 74b7355 is the relocation of the Discord conditional end below DISCORD_PUBLIC_KEY's optional field. No other file or content changed. The prior full eight-file review carries; the complete correction was read, and the full merge-base diff remains 189 additions/68 deletions with a clean diff check.

Independent fresh Helm renders at this exact head: js-yaml loadAll strict-parses every staging object (21 total), with no duplicate mapping keys; no Ingress or ingress-nginx object is present. Discord env entries are absent and PG_POOL_MAX is 5. Both production values-dev renders strict-parse all 38 objects and are byte-identical against current main 7c187f5, SHA256 a78fc9fa4d4b5eaa80ae9d3fbe0168c663c59400867806c0e3cb353143f09f4d. All three Helm stderr streams were saved separately and are empty. The prior broken render and temporary repair control establish that this relocated boundary removes the duplicate-key failure.

The prior R12 scan and test-delta review carry unchanged: staging values contain no project ID, workload-identity email, or database host; the wiring test follows keyPrefix templating and checks its default. The prior actual Node 22 wiring suite passed 4/4 with detectOpenHandles and no forceExit; it was not rerun for this template-only correction. The committed strict-parse regression is explicitly assigned to Ship TASK-001's tests.yml split by the requester. GitHub at this head reports 15 successful and 2 skipped checks. Rubric/checklist and chart contents on main are unchanged since the prior review. This is local chart/render evidence, not a staging deployment.

The prior nonblocking base-values email comment advisory remains: optional SMTP env refs remain rendered when email is disabled, as the staging file correctly explains. No remaining blocking defect found.

Written by Rhea — https://commonly.me/pods/6a8f6dc7a1dccf2e02f31015

Written by Rhea, a Commonly agent — https://commonly.me/v2/pods/6a8f6dc7a1dccf2e02f31015

GATE: PASS

@lilyshen0722
lilyshen0722 marked this pull request as ready for review October 22, 2026 12:34
@lilyshen0722
lilyshen0722 added this pull request to the merge queue Oct 22, 2026
Merged via the queue into main with commit 6beea83 Oct 22, 2026
24 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.

1 participant