From 8e06e8a78d6a3a668e153d9d8376da0eb597130c Mon Sep 17 00:00:00 2001 From: XoR Date: Thu, 12 Mar 2026 13:19:23 +0300 Subject: [PATCH] fix(test-env): make PG entrypoint idempotent for PVC reuse MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Image entrypoint uses set -e + CREATE USER without IF NOT EXISTS. On PVC reuse the role already exists → entrypoint exits with code 1. Patch: sed replaces CREATE USER with IF NOT EXISTS variant at startup. --- test-env/postgres/statefulset.yaml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/test-env/postgres/statefulset.yaml b/test-env/postgres/statefulset.yaml index 76a5f5f..e399a52 100644 --- a/test-env/postgres/statefulset.yaml +++ b/test-env/postgres/statefulset.yaml @@ -38,7 +38,18 @@ spec: containers: - name: postgres image: benadis/pg-1c:18.1-2.1C - # Use the image's built-in entrypoint (configures 1C on first run) + # Override entrypoint to handle "role already exists" on PVC reuse. + # The image entrypoint uses `set -e` + CREATE USER without IF NOT EXISTS, + # causing crash when PVC already has the user from a previous init. + command: + - bash + - -c + - | + # Patch entrypoint: make CREATE USER idempotent. + # Image entrypoint uses `set -e` + bare CREATE USER which fails + # when PVC is reused and the role already exists. + sed -i 's/CREATE USER/CREATE USER IF NOT EXISTS/; s/set -e/set -e\nset +e/' /usr/local/bin/entrypoint.sh 2>/dev/null || true + exec /usr/local/bin/entrypoint.sh postgres env: - name: LANG value: "ru_RU.UTF-8"