From 3e266a2a381ffe13b5a90f1b14a161d77961ade4 Mon Sep 17 00:00:00 2001 From: ymichaelson Date: Wed, 12 Aug 2026 11:43:34 +0800 Subject: [PATCH] fix(db): seed postgresql-custom idempotently instead of empty-dir check The init-pgsodium container gated the copy of default postgresql-custom config files on the pgsodium volume being empty ([ -z "$(ls -A)" ]). On block-storage volumes (EBS, GCE PD, Ceph RBD, OpenEBS LVM, ...) the filesystem is formatted ext4/xfs and ships a lost+found directory, so the volume is never truly empty on first use. The copy was skipped, leaving /etc/postgresql-custom/*.conf missing and postgres failing to start with "configuration file postgresql.conf contains errors" (CrashLoopBackOff). Replace the emptiness check with an idempotent no-clobber copy (cp -an): it seeds any missing config files on every start without overwriting existing ones, preserving runtime-generated pgsodium keys (the reason the persistent volume was introduced in #197). --- charts/supabase/Chart.yaml | 2 +- charts/supabase/templates/db/statefulset.yaml | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/charts/supabase/Chart.yaml b/charts/supabase/Chart.yaml index 83c34661..c3c2905b 100644 --- a/charts/supabase/Chart.yaml +++ b/charts/supabase/Chart.yaml @@ -15,7 +15,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.7.2 +version: 0.7.3 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/charts/supabase/templates/db/statefulset.yaml b/charts/supabase/templates/db/statefulset.yaml index b845b12d..5a791e56 100644 --- a/charts/supabase/templates/db/statefulset.yaml +++ b/charts/supabase/templates/db/statefulset.yaml @@ -62,13 +62,15 @@ spec: command: ["/bin/sh", "-c"] args: - | - echo "Initializing pgsodium persistent config directory..." - if [ -z "$(ls -A /mnt/pgsodium 2>/dev/null)" ]; then - echo "pgsodium volume is empty, copying default postgresql-custom files..." - cp -a /etc/postgresql-custom/. /mnt/pgsodium/ - else - echo "pgsodium volume already initialized, skipping copy" - fi + echo "Ensuring default postgresql-custom files exist..." + # Idempotent, no-clobber copy: seeds any missing config files without + # overwriting existing ones (preserves runtime-generated pgsodium keys). + # An emptiness check ([ -z "$(ls -A)" ]) is unreliable here: block-storage + # volumes (EBS, GCE PD, Ceph RBD, OpenEBS LVM, ...) are formatted ext4/xfs + # and ship a lost+found directory, so the volume is never truly empty on + # first use, the copy was skipped, and postgres could not open its + # included /etc/postgresql-custom/*.conf files (CrashLoopBackOff). + cp -an /etc/postgresql-custom/. /mnt/pgsodium/ 2>/dev/null || true volumeMounts: - mountPath: /mnt/pgsodium name: pgsodium