Skip to content

fix(secrets): seed image-gallery's role credential on GCP too - #2037

Merged
Smana merged 1 commit into
mainfrom
fix/secret-store-seed-image-gallery-on-gcp
Sep 13, 2026
Merged

Smana merged 1 commit into
mainfrom
fix/secret-store-seed-image-gallery-on-gcp

Conversation

@Smana

@Smana Smana commented Sep 13, 2026

Copy link
Copy Markdown
Owner

What

GENERATABLE in scripts/secret-store.sh gated image-gallery's CNPG role credential behind if [ "$CLOUD" = "aws" ]. This lists it unconditionally, so it resolves through _cnpg_sep on both clouds.

Why

The gate was correct when written — apps/base/complete was absent from apps/gcp-0/kustomization.yaml, the app reached S3 with its bucket hardcoded in the container environment, and gcp-0 had no image-gallery, no SQLInstance for it and no ExternalSecret reading the key. Seeding it there would have created a paid, permanently-unread secret.

image-gallery v2 (#2022) falsified every clause of that. apps/gcp-0 now includes ../base/complete, the app selects its backend with STORAGE_PROVIDER=gcs against a real GCS bucket, and gcp-0 has both the SQLInstance and the ExternalSecret.

Observed

On gcp-0 today, after #2022 reached the cluster: External Secrets could not read cnpg-xplane-image-gallery-roles-image-gallery-app, and both app replicas and the CNPG initdb pod sat in CreateContainerConfigError naming a Kubernetes Secret.

initdb needing that credential is what makes this a deadlock rather than an ordering problem: CNPG cannot seed a secret it requires in order to start, so nothing converges on its own. That is precisely the failure the comment above GENERATABLE warns about — "seeded here so a rebuild does not depend on someone remembering".

Scope

seed_body needed no change. Its case pattern is cnpg?xplane-image-gallery?roles?image-gallery-app, where ? matches either separator, so the generator half was cloud-agnostic all along. Only the list excluded GCP. No bao_target_for entry either: like the other two cnpg/* keys, this one stays in the cloud store because the SQLInstance composition hardcodes secretStoreRef.name: clustersecretstore, and migrate reports unmapped keys as skipped (unmapped).

Verification

  • seed --cloud gcp (dry-run) resolves to cnpg-xplane-image-gallery-roles-image-gallery-app — character-for-character the key the cluster asked for.
  • seed --cloud aws keeps the slash spelling, unchanged for aws-0.
  • shellcheck -x -S warning clean; the two info-level findings (SC1091, SC2016 at lines 81 and 287) are identical before and after and predate this change.
  • test-cloud-secret-store.sh and test-cnpg-promote-seed.sh both pass.

After merge

scripts/secret-store.sh seed --cloud gcp --apply creates the secret. It never overwrites an existing one, so it is safe to re-run. Note the ORDER MATTERS warning in seed_body: CNPG fixes the role password when it creates the cluster — currently safe, because initdb has not run.

The entry was appended under `if [ "$CLOUD" = "aws" ]`, which was correct when
written: apps/base/complete was absent from apps/gcp-0/kustomization.yaml, the
application reached S3 with its bucket hardcoded in the container environment,
and gcp-0 had no image-gallery, no SQLInstance for it and no ExternalSecret
reading the key. Seeding it there would have created a paid, unread secret.

image-gallery v2 (#2022) made every clause of that false. apps/gcp-0 now
includes ../base/complete, the app selects its backend with STORAGE_PROVIDER=gcs
against a real GCS bucket, and gcp-0 has both the SQLInstance and the
ExternalSecret.

Observed on gcp-0 today: External Secrets could not read
cnpg-xplane-image-gallery-roles-image-gallery-app, and both app replicas AND the
CNPG initdb pod sat in CreateContainerConfigError naming a Kubernetes Secret.
initdb needing that credential is what makes it a deadlock rather than an
ordering problem — CNPG cannot seed a secret it requires in order to start, so
nothing converges on its own.

seed_body needed no change: its case pattern is
`cnpg?xplane-image-gallery?roles?image-gallery-app`, where `?` matches either
separator, so the generator half was already cloud-agnostic. Only GENERATABLE
excluded GCP.

Verified: `seed --cloud gcp` dry-runs to
`cnpg-xplane-image-gallery-roles-image-gallery-app`, matching the key the
cluster asked for; `seed --cloud aws` keeps the slash spelling unchanged.
shellcheck -x -S warning is clean, and test-cloud-secret-store.sh and
test-cnpg-promote-seed.sh both pass.
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Rendered manifest diff — this PR vs main (desired state)

No changes to the rendered desired state. ✅

@Smana
Smana merged commit 29b480d into main Sep 13, 2026
8 checks passed
@Smana
Smana deleted the fix/secret-store-seed-image-gallery-on-gcp branch September 13, 2026 07:58
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