Skip to content

Commit 17b8238

Browse files
committed
fix(hosting): fail the upgrade when secrets.existingSecret is missing keys
When secrets.existingSecret is set the chart generates nothing and reads every application and control-plane key from that Secret. A chart version that starts consuming a new key therefore breaks the webapp rollout with a CreateContainerConfigError partway through, leaving the release half-applied. The pre-install/pre-upgrade validation now looks the Secret up and fails with the full list of missing keys, so a running release is left untouched. The lookup returns nothing under helm template and client-side dry-run, where the check is skipped rather than guessing.
1 parent 1db7842 commit 17b8238

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

hosting/k8s/helm/templates/validate-external-config.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,36 @@ Application and control-plane secrets are auto-generated by templates/secrets.ya
5454
when left unset (retained across upgrades via lookup), so they need no fail-closed
5555
guard here. The webapp still rejects previously published values at startup, even
5656
when supplied via secrets.existingSecret.
57+
58+
With secrets.existingSecret the chart generates nothing, so every key the workloads
59+
reference has to already be present in that Secret. Report missing keys up front -
60+
otherwise a chart version that starts consuming a new key only surfaces it as a
61+
CreateContainerConfigError partway through the rollout. The check is skipped when
62+
`lookup` returns nothing (helm template, client-side dry-run, or a Secret created
63+
later in the same apply): it can only report on what it can read.
5764
*/}}
65+
{{- if .Values.secrets.existingSecret }}
66+
{{- $required := list "SESSION_SECRET" "MAGIC_LINK_SECRET" "ENCRYPTION_KEY" "PROVIDER_SECRET" "COORDINATOR_SECRET" "MANAGED_WORKER_SECRET" }}
67+
{{- if and .Values.s3.deploy (not .Values.s3.auth.existingSecret) }}
68+
{{- $required = concat $required (list "s3-auth-access-key-id" "s3-auth-secret-access-key") }}
69+
{{- end }}
70+
{{- if and (not .Values.s3.deploy) (not .Values.s3.external.existingSecret) .Values.s3.external.accessKeyId }}
71+
{{- $required = concat $required (list "s3-access-key-id" "s3-secret-access-key") }}
72+
{{- end }}
73+
{{- $found := lookup "v1" "Secret" .Release.Namespace .Values.secrets.existingSecret }}
74+
{{- if $found }}
75+
{{- $data := (get $found "data") | default dict }}
76+
{{- $missing := list }}
77+
{{- range $key := $required }}
78+
{{- if not (hasKey $data $key) }}
79+
{{- $missing = append $missing $key }}
80+
{{- end }}
81+
{{- end }}
82+
{{- if $missing }}
83+
{{- fail (printf "Secret %q (secrets.existingSecret) is missing required keys: %s. Add them before upgrading - while secrets.existingSecret is set the chart generates nothing and inline secrets.* values are ignored. See https://trigger.dev/docs/self-hosting/kubernetes#upgrading" .Values.secrets.existingSecret (join ", " $missing)) }}
84+
{{- end }}
85+
{{- end }}
86+
{{- end }}
5887

5988
{{/*
6089
This template produces no output but will fail the deployment if validation fails

0 commit comments

Comments
 (0)