Repository navigation
Fix the staging deploy: put the usage collector's generated credentials in Secret data - #1880
Merged
Merged
Conversation
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.pyrunspulumi preview --save-planand thenpulumi up --plan. The Kubernetes provider moves a Secret'sstringDataintodataonce it knows the values. Four of the usage collector's Secrets took values that are random passwords, unknown at preview:registry-usage-*-passwordSecrets (role name and generated password)registry-usage-collector(the two database addresses, which contain those passwords)For those, the plan recorded
stringDataand the apply presenteddatainstead, so Pulumi rejected the resource:The repository's older Secrets that use
stringDatatake values known at preview (configuration), so they are not affected.registry-usage-collector-gcpalready useddata, which is why it was created.Fix
Those four Secrets now supply base64 values in
datadirectly, 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 usesstringData.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.
stringDatawith 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.datapasses in each. This rules out the CLI version, the random provider and the mixed map as causes.k8s.DeployMonitoringStackwith staging's configuration, and a stand-in for the Google key):"true"registry-usage-collector-passwordwith the message above, leaving a partial state like staging's"true", on that partial stateNo 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 throughsecretKeyRef.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
DatabaseRoleobjects, theDatabase, 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.gohas an older Secret (AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEYfrom 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-collectorimage package public, then start the first run by hand.