Skip to content

Fix the staging deploy: put the usage collector's generated credentials in Secret data - #1880

Merged
rdimitrov merged 1 commit into
mainfrom
rdimitrov-usage-collector-plan-fix
Nov 20, 2026
Merged

rdimitrov merged 1 commit into
mainfrom
rdimitrov-usage-collector-plan-fix

Conversation

@rdimitrov

Copy link
Copy Markdown
Member

The staging deploy that followed #1878 failed while applying its saved plan (apply-failed-plan-constraint,resource-secret), and that blocks every later staging deploy. This fixes it.

Cause

deploy/scripts/deploy_stack.py runs pulumi preview --save-plan and then pulumi up --plan. The Kubernetes provider moves a Secret's stringData into data once it knows the values. Four of the usage collector's Secrets took values that are random passwords, unknown at preview:

  • the three registry-usage-*-password Secrets (role name and generated password)
  • registry-usage-collector (the two database addresses, which contain those passwords)

For those, the plan recorded stringData and the apply presented data instead, so Pulumi rejected the resource:

kubernetes:core/v1:Secret::registry-usage-collector-password violates plan:
properties changed: +-stringData[...], =+data[...]

The repository's older Secrets that use stringData take values known at preview (configuration), so they are not affected. registry-usage-collector-gcp already used data, which is why it was created.

Fix

Those four Secrets now supply base64 values in data directly, which has the same shape at preview and at apply. Values remain Pulumi secrets; nothing moves into chart values, ConfigMaps or logs. A test asserts that no usage Secret uses stringData.

How it was checked

Nothing was run against the staging or production stack. Everything below used Pulumi CLI 3.188.0 (the version CI pins), a local file backend and the Kubernetes provider rendering manifests to a directory.

  1. Small programs with the Secret shapes. stringData with a value unknown at preview fails in every variant tried: mixed with a known value, alone, the whole map as one output, wrapped as a secret, with and without the optional aliases. data passes in each. This rules out the CLI version, the random provider and the mixed map as causes.
  2. The real program (k8s.DeployMonitoringStack with staging's configuration, and a stand-in for the Google key):
Step Program Result
1 main before the fix, flag unset applied
2 main before the fix, flag "true" preview lists 18 creates and 2 updates; apply fails on registry-usage-collector-password with the message above, leaving a partial state like staging's
3 this branch, flag "true", on that partial state preview lists 10 creates and 1 update (the Grafana Deployment, in place); apply succeeds
4 this branch again no changes

No resource was replaced or deleted in step 3, and the stand-in key kept its id and creation time. The rendered Secrets hold the role names, 32-character passwords and the two addresses under data; Grafana reads its password through secretKeyRef.

go -C deploy test ./... and the script tests pass.

What the next staging deploy does

It creates what the failed apply did not reach: the four Secrets, the three DatabaseRole objects, the Database, and both CronJobs, and it updates Grafana. Resources that already exist (bucket, service account key, IAM grant, registry-usage-collector-gcp, PVC, PriorityClass, the two dashboard ConfigMaps) have unchanged inputs and are left as they are. The service account key is not recreated.

The local reproduction stops at the first failing resource, as staging did, so this deploy is the first time the CNPG objects, the CronJobs and the Grafana update are applied to a real cluster. A server-side dry run of the four CNPG objects was accepted in staging earlier.

Not changed

deploy/pkg/providers/gcp/provider.go has an older Secret (AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY from an HMAC key) with the same pattern. It exists in both stacks and deploys today; it would hit this error only if its key were created or replaced in a planned deployment. Left for a separate change.

The manual steps after a successful deploy are unchanged from #1878: make the registry-usage-collector image package public, then start the first run by hand.

The staging deployment of the usage collector failed while applying its
saved plan: the Secrets holding the generated role passwords and the two
database addresses were rejected as violating the plan.

The Kubernetes provider moves a Secret's stringData into data once it
knows the values. These values are random passwords, unknown at preview,
so the plan recorded stringData and the apply presented data instead.
The Secrets now supply base64 values in data directly, which is the
same at preview and at apply.

A test asserts that no usage Secret uses stringData.

Co-authored-by: Copilot App <[email protected]>
@rdimitrov
rdimitrov merged commit b72e28f into main Nov 20, 2026
9 checks passed
@rdimitrov
rdimitrov deleted the rdimitrov-usage-collector-plan-fix branch November 20, 2026 21:19
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