Skip to content

Commit cf9fa0d

Browse files
authored
Merge pull request #41924 from appsmithorg/fm/redis-pw-guard-v3
fix(helm): reject unsupported redis.auth.password configurations
2 parents 4e79144 + f175f91 commit cf9fa0d

4 files changed

Lines changed: 39 additions & 2 deletions

File tree

deploy/helm/templates/_helpers.tpl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,27 @@ Uses existing secret if provided, otherwise derives "{release}-redis-secret"
237237
{{- .Values.redis.auth.existingSecret | default (printf "%s-redis-secret" .Release.Name) -}}
238238
{{- end -}}
239239

240+
{{/*
241+
Redis: validate the redis.auth.password configuration.
242+
243+
redis.auth.password is a Bitnami subchart passthrough that the Appsmith
244+
templates never read on their own. There is exactly ONE supported way to use
245+
it: the fully self-managed path, where the operator also disables the chart's
246+
bootstrap secret (existingSecret: "") and hands the app a matching connection
247+
string via applicationConfig.APPSMITH_REDIS_URL. Any other use silently splits
248+
the password between Redis and the app, so we fail fast instead.
249+
250+
Invoked from a template that always renders (configMap.yaml) so it evaluates on
251+
every `helm template`/install/upgrade.
252+
*/}}
253+
{{- define "appsmith.validateRedisAuth" -}}
254+
{{- if .Values.redis.auth.password -}}
255+
{{- if or .Values.redis.auth.existingSecret (not .Values.applicationConfig.APPSMITH_REDIS_URL) -}}
256+
{{ fail (printf "redis.auth.password is set, which is only supported on the self-managed path. Choose one of:\n 1. Leave redis.auth.password unset and let the chart bootstrap a password (default), or supply your own secret via redis.auth.existingSecret / redis.auth.existingSecretPasswordKey.\n 2. Self-manage the password: set redis.auth.password, set redis.auth.existingSecret: \"\", and set applicationConfig.APPSMITH_REDIS_URL=redis://:<password>@%s-redis-master:6379 so the app uses the same credential." .Release.Name) }}
257+
{{- end -}}
258+
{{- end -}}
259+
{{- end -}}
260+
240261
{{/*
241262
Redis: master service hostname (FQDN inside the cluster).
242263
Derived from the release name to stay uniform with the chart's other components.

deploy/helm/templates/configMap.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
{{- $postgresqlPassword := .Values.postgresql.auth.password -}}
77
{{- $postgresqlDatabase := .Values.postgresql.auth.database -}}
88
{{- $releaseName := .Release.Name -}}
9+
{{- include "appsmith.validateRedisAuth" . -}}
910
apiVersion: v1
1011
kind: ConfigMap
1112
metadata:

deploy/helm/templates/deployment.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,13 @@ spec:
8080
image: "{{ .Values.redis.image.registry }}/{{ .Values.redis.image.repository }}:{{ .Values.redis.image.tag }}"
8181
{{- end }}
8282
command: ['sh', '-c', "until redis-cli -h {{ include "appsmith.redisMasterHost" . }} ping ; do echo waiting for redis; sleep 2; done"]
83-
{{- if .Values.redis.auth.enabled }}
83+
{{- if and .Values.redis.auth.enabled (not .Values.applicationConfig.APPSMITH_REDIS_URL) }}
84+
# Pull the password from the chart-managed Secret so the readiness ping can
85+
# authenticate. Skipped when the operator supplies their own APPSMITH_REDIS_URL
86+
# (the self-managed redis.auth.password path), because then no chart Secret exists
87+
# to reference and an unresolvable secretKeyRef would wedge the pod in
88+
# CreateContainerConfigError. The wait still works unauthenticated: `redis-cli ping`
89+
# against an auth-required server replies NOAUTH but exits 0, satisfying the loop.
8490
env:
8591
- name: REDISCLI_AUTH
8692
valueFrom:

deploy/helm/templates/hooks/redis.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,16 @@ secret (or a user who pre-created their own) is left untouched.
1414
The resulting Secret has no Helm release labels/annotations and no
1515
ownerReferences, so ArgoCD does not track or diff it.
1616
*/}}
17-
{{- if and .Values.redis.enabled .Values.redis.auth.enabled }}
17+
{{/*
18+
Skip the bootstrap entirely when redis.auth.password is set: on that path the
19+
operator self-manages the credential (Bitnami uses redis.auth.password directly)
20+
and there is no chart secret to create. Safe ONLY because appsmith.validateRedisAuth
21+
(see _helpers.tpl, invoked from configMap.yaml) rejects every redis.auth.password
22+
configuration except the self-managed one (existingSecret: "" + a matching
23+
APPSMITH_REDIS_URL) — so this can no longer leave a non-empty existingSecret
24+
pointing at a secret the hook never creates.
25+
*/}}
26+
{{- if and .Values.redis.enabled .Values.redis.auth.enabled (not .Values.redis.auth.password) }}
1827
{{- $secretName := include "appsmith.redisSecretName" . -}}
1928
{{- $passwordKey := .Values.redis.auth.existingSecretPasswordKey -}}
2029
{{- $jobName := printf "%s-redis-password-init" (include "appsmith.fullname" .) | trunc 63 | trimSuffix "-" -}}

0 commit comments

Comments
 (0)