pgdogdev/helm · issue #121
A bad config rolls out to every PgDog pod, because the Helm chart has no readiness probe.
A default readiness probe on PgDog's own healthcheck endpoint stops the rollout at the first broken pod, and the old pods keep serving. This is the approach Lev suggested in #121, recorded on a kind cluster.
Same typo, two charts
2 replicas, the chart's default values, Postgres 18 in the cluster. The values change has a typo in the database host. rollout restart is how a config change reaches pods, since PgDog reloads most settings in place and the chart doesn't roll pods for a ConfigMap change.
$ helm upgrade pgdog pgdogdev/pgdog -f bad.yaml # host: postgres-primary (typo)$ kubectl rollout restart deploy/pgdogWaiting for deployment "pgdog" rollout to finish: 1 out of 2 new replicas have been updated...(5 more Waiting lines)deployment "pgdog" successfully rolled out # 05:21:55 → 05:21:57$ kubectl get podspgdog-5d864f4bc5-5885d 0/1 Completed 0 24spgdog-5d864f4bc5-srgkk 1/1 Terminating 0 24spgdog-8884db45c-54jmp 1/1 Running 0 1spgdog-8884db45c-cmkz7 1/1 Running 0 2s$ psql -h pgdog -p 6432 -U postgres -d app -c 'select 1' # 3 triesERROR: connection pool for user "postgres" and database "app" is downERROR: connection pool for user "postgres" and database "app" is downERROR: connection pool for user "postgres" and database "app" is down
$ helm upgrade pgdog ./helm -f bad.yaml # same typo, chart with the fix$ kubectl rollout restart deploy/pgdogerror: timed out waiting for the condition # rollout stopped$ kubectl get podspgdog-5f7984bd86-vzpcn 0/1 Running 0 45s # new pod, readiness 502pgdog-86b8f4f5fd-4zlqn 1/1 Running 0 67s # old pods keep servingpgdog-86b8f4f5fd-mfgh4 1/1 Running 0 56s$ psql -h pgdog -p 6432 -U postgres -d app -c 'select 1' # 3 tries111Same result on 3 of 3 runs, and with an unreachable IP instead of a typo.
The change
Three files, +38/−4 including a test. The probe is added only when you haven't set your own.
# values.yaml-# healthcheckPort: 8080+healthcheckPort: 8080# templates/deployment.yaml (container ports)+ {{- if .Values.healthcheckPort }}+ - name: healthcheck+ containerPort: {{ .Values.healthcheckPort }}+ {{- end }}# templates/deployment.yaml (probes){{- if .Values.readinessProbe }}readinessProbe:{{- toYaml .Values.readinessProbe | nindent 12 }}+ {{- else if .Values.healthcheckPort }}+ readinessProbe:+ initialDelaySeconds: 10+ httpGet:+ path: /+ port: healthcheck{{- end }}
What else was checked
One database down of two
The endpoint only returns 502 when every pool is down, so the pod stays ready and the healthy database keeps serving.
Postgres outage
With Postgres scaled to 0 for 45 s, every pod went NotReady. About 20 s after Postgres came back they were Ready again, with no client traffic.
Why the 10 s delay
Pools start out healthy until their first connect fails (up to connect_timeout, 5 s), so the probe waits 10 s. Starting pools as unknown in pgdog would remove the need.
Readiness only
There's no liveness probe on this endpoint, because restarting PgDog during a database outage would drop every client and wouldn't help.
Upgrade change
Installs without a readinessProbe get healthcheck_port = 8080 and the probe. A user-set probe is kept, and healthcheckPort: null turns it off. With service.aws.enabled, the NLB switches to its HTTP check (not tested on EKS).
Their CI, locally
test/test.sh passes on all 34 values files, plus a new check that fails if either the template or the values change is reverted.
Rerun it
The values files, Postgres manifest and logs are in the demo repo. With kind and helm installed: create a cluster, apply pg.yaml, install the chart with good.yaml, then upgrade with bad.yaml and run kubectl rollout restart deploy/pgdog.