fix: address review of the Postgres move

- close the pool on SIGTERM before exiting; query_timeout on the pool
- SIGTERM test fails instead of hanging; test cleanup in finally
- preStop sleep so rollouts don't drop form posts; Postgres startupProbe
- CI step timeout, clear error if test Postgres never starts, remove test image
- export stops on SQL errors; README note on changing the DB password

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfmHGGiYUjNcvJoyzdf
This commit is contained in:
ngqileandClaude Opus 5.5 committed 2026-12-01 11:59:55 +08:00
1 parent 20e07e9d80
commit ad5996283e
7 files changed
+42 -14

No files matched your search

+3 -1
View File
@@ -52,6 +52,7 @@ jobs:
"$GITHUB_WORKSPACE/scripts/waitForOlderRuns.sh" "$RUN_NUMBER"
- name: Docker build & push
timeout-minutes: 20
env:
REGISTRY_USER: ${{ secrets.PACKAGE_USER }}
REGISTRY_PASSWORD: ${{ secrets.PACKAGE_RW_KEY }}
@@ -66,12 +67,13 @@ jobs:
printf '%s' "$REGISTRY_PASSWORD" | docker login "$_REGISTRY" -u "$REGISTRY_USER" --password-stdin
# Tests need Postgres: run them in the test stage against a throwaway one on its own network.
T="ins-ci-$GITHUB_RUN_ID"
trap 'docker rm -f "$T-pg" >/dev/null 2>&1; docker network rm "$T" >/dev/null 2>&1' EXIT
trap 'docker rm -f "$T-pg" >/dev/null 2>&1; docker network rm "$T" >/dev/null 2>&1; docker rmi -f "$T-test" >/dev/null 2>&1' EXIT
docker build --pull -f Dockerfile --target test -t "$T-test" .
docker network create "$T"
docker run -d --name "$T-pg" --network "$T" -e POSTGRES_USER=ci -e POSTGRES_DB=ci -e POSTGRES_PASSWORD=ci postgres:18
# -h 127.0.0.1: the image first starts a socket-only init server; TCP answers only once it is really up
for i in $(seq 1 30); do docker exec "$T-pg" pg_isready -h 127.0.0.1 -U ci -d ci && break; sleep 2; done
docker exec "$T-pg" pg_isready -h 127.0.0.1 -U ci -d ci || { echo "Postgres for tests did not start"; docker logs "$T-pg"; exit 1; }
docker run --rm --network "$T" -e TEST_DATABASE_URL="postgres://ci:ci@$T-pg:5432/ci" "$T-test"
docker build -f Dockerfile -t "$IMAGE_REF" .
docker push "$IMAGE_REF"