diff --git a/.github/workflows/betacrew-safety.yml b/.github/workflows/betacrew-safety.yml index a585584..fb9bed2 100644 --- a/.github/workflows/betacrew-safety.yml +++ b/.github/workflows/betacrew-safety.yml @@ -20,6 +20,10 @@ jobs: run: python3 scripts/test-betacrew-safety.py - name: Real encrypted database restore over verified TLS run: python3 scripts/test-betacrew-encrypted-restore.py + - name: Verify configured fallback backup image + run: | + POSTGRES_TEST_IMAGE=$(sed -n 's/.*BETACREW_BACKUP_IMAGE:-\([^}]*\)}.*/\1/p' compose.host.yml) \ + python3 scripts/test-betacrew-encrypted-restore.py - name: Encryption contract (mock database dump) run: bash scripts/test-betacrew-backup.sh - name: Configuration and shell syntax diff --git a/.github/workflows/jotwink-safety.yml b/.github/workflows/jotwink-safety.yml index 60ed7f1..390348e 100644 --- a/.github/workflows/jotwink-safety.yml +++ b/.github/workflows/jotwink-safety.yml @@ -20,6 +20,10 @@ jobs: run: python3 scripts/test-jotwink-safety.py - name: Real encrypted database restore over verified TLS run: python3 scripts/test-jotwink-encrypted-restore.py + - name: Verify configured fallback backup image + run: | + POSTGRES_TEST_IMAGE=$(sed -n 's/.*JOTWINK_BACKUP_IMAGE:-\([^}]*\)}.*/\1/p' compose.host.yml) \ + python3 scripts/test-jotwink-encrypted-restore.py - name: Encryption contract (mock database dump) run: bash scripts/test-jotwink-backup.sh - name: Configuration and shell syntax diff --git a/README.md b/README.md index 803f5de..e4b6200 100644 --- a/README.md +++ b/README.md @@ -923,19 +923,19 @@ script at `/srv/makepad/visitaki-backups/visitaki-encrypted-backup.py` and the t pass. Enable only the Visitaki timer; preserve other applications' jobs. MinIO objects require separate backup coverage. -## PostgreSQL 18 default and existing clusters +## PostgreSQL 19 default and existing clusters The configuration validator requires matching immutable fallback digests across the base, host and backup-service Compose references. Regression tests reject a split fallback pin and an accidental production major-version override change. -The Compose fallback image is PostgreSQL 18. Production and canary environment +The Compose fallback image is PostgreSQL 19. Production and canary environment files still explicitly select PostgreSQL 16; changing the default does not perform a production major upgrade. Both Compose entry points set `PGDATA` explicitly to `/var/lib/postgresql/data`, matching the existing bind mount for either version. -Without this setting, the PostgreSQL 18 image rejects that legacy mount layout. +Without this setting, the PostgreSQL 19 image rejects that legacy mount layout. -Never point PostgreSQL 18 at an existing 16 data directory as an upgrade method. +Never point PostgreSQL 19 at an existing 16 data directory as an upgrade method. The server must refuse that directory, and the 16 image must be able to restart it unchanged. A real major upgrade requires a separate target directory, verified backup/restore or a reviewed `pg_upgrade` procedure, application compatibility @@ -943,7 +943,7 @@ checks, and an explicit cutover of the environment pin. Keep the predecessor directory and backup until rollback acceptance is complete. `./scripts/test-postgres-major-compat.sh` uses isolated volumes and synthetic rows -to check fresh 18 persistence, logical 16-to-18 restore, refusal of an in-place +to check fresh 19 persistence, logical 16-to-19 restore, refusal of an in-place image swap, and successful restart of the untouched 16 cluster. These tests do not authorize or claim a production data migration. diff --git a/compose.betacrew.host.yml b/compose.betacrew.host.yml index 2ff8b29..7d88f87 100644 --- a/compose.betacrew.host.yml +++ b/compose.betacrew.host.yml @@ -1,6 +1,6 @@ services: betacrew_backup: - image: ${BETACREW_BACKUP_IMAGE:-postgres:18-bookworm@sha256:e742a2668255221388004f3a42b6150a2103f5054ab3a4a93ae9e4f01e551c35} + image: ${BETACREW_BACKUP_IMAGE:-postgres:19-bookworm@sha256:f4859caf96de494e38efa69ed703b08a5bbd9605e152e604f2daec8841c87c41} user: "999:999" network_mode: host command: [/usr/local/bin/run-betacrew-backup-loop.sh] diff --git a/compose.host.yml b/compose.host.yml index 7614fe9..04b56dc 100644 --- a/compose.host.yml +++ b/compose.host.yml @@ -1,6 +1,6 @@ services: postgres: - image: ${POSTGRES_IMAGE:-postgres:18-alpine@sha256:0115267ab5a509022df9319c77be365cef335adb71556c75f60f5360ee247e71} + image: ${POSTGRES_IMAGE:-postgres:19-alpine@sha256:cac45fb483caee3668946088a1c0532db89d5285c28dbfeac889b4068296e06f} network_mode: host environment: PGDATA: /var/lib/postgresql/data @@ -38,7 +38,7 @@ services: max-file: "${MAKEPAD_POSTGRES_LOG_MAX_FILES:-5}" runtrace_backup: - image: ${POSTGRES_IMAGE:-postgres:18-alpine@sha256:0115267ab5a509022df9319c77be365cef335adb71556c75f60f5360ee247e71} + image: ${POSTGRES_IMAGE:-postgres:19-alpine@sha256:cac45fb483caee3668946088a1c0532db89d5285c28dbfeac889b4068296e06f} user: "70:70" network_mode: host command: @@ -134,7 +134,7 @@ services: max-file: "${MAKEPAD_POSTGRES_BACKUP_LOG_MAX_FILES:-5}" jotwink_backup: - image: ${JOTWINK_BACKUP_IMAGE:-postgres:18-bookworm@sha256:e742a2668255221388004f3a42b6150a2103f5054ab3a4a93ae9e4f01e551c35} + image: ${JOTWINK_BACKUP_IMAGE:-postgres:19-bookworm@sha256:f4859caf96de494e38efa69ed703b08a5bbd9605e152e604f2daec8841c87c41} profiles: [jotwink] user: "999:999" network_mode: host @@ -183,7 +183,7 @@ services: max-file: "${MAKEPAD_POSTGRES_BACKUP_LOG_MAX_FILES:-5}" betacrew_backup: - image: ${BETACREW_BACKUP_IMAGE:-postgres:18-bookworm@sha256:e742a2668255221388004f3a42b6150a2103f5054ab3a4a93ae9e4f01e551c35} + image: ${BETACREW_BACKUP_IMAGE:-postgres:19-bookworm@sha256:f4859caf96de494e38efa69ed703b08a5bbd9605e152e604f2daec8841c87c41} profiles: [betacrew] user: "999:999" network_mode: host diff --git a/compose.yml b/compose.yml index 60aad0e..02f5e4b 100644 --- a/compose.yml +++ b/compose.yml @@ -1,6 +1,6 @@ services: postgres: - image: ${POSTGRES_IMAGE:-postgres:18-alpine@sha256:0115267ab5a509022df9319c77be365cef335adb71556c75f60f5360ee247e71} + image: ${POSTGRES_IMAGE:-postgres:19-alpine@sha256:cac45fb483caee3668946088a1c0532db89d5285c28dbfeac889b4068296e06f} environment: PGDATA: /var/lib/postgresql/data command: diff --git a/docs/postgresql-18-upgrade.md b/docs/postgresql-19-upgrade.md similarity index 75% rename from docs/postgresql-18-upgrade.md rename to docs/postgresql-19-upgrade.md index 5d8be5c..ad1bead 100644 --- a/docs/postgresql-18-upgrade.md +++ b/docs/postgresql-19-upgrade.md @@ -1,8 +1,9 @@ -# PostgreSQL 18 major-version upgrade +# PostgreSQL 19 major-version upgrade -The repository is pinned to PostgreSQL 18. `scripts/preflight-postgres-major.sh` -refuses to start that image against a data directory initialized by an older -major version. A normal deploy is not an upgrade mechanism. +The Compose fallback is pinned to PostgreSQL 19; the production and canary +environment files retain PostgreSQL 16. `scripts/preflight-postgres-major.sh` +refuses to start the fallback image against a data directory initialized by an +older major version. A normal deploy is not an upgrade mechanism. ## Required gate @@ -12,11 +13,11 @@ stopping writers, require all of the following: - a fresh certificate-verified logical backup of every database, including `amiary`, `amiary_canary`, and `keycloak_amiary`; - verified checksums and `pg_restore --list` for every custom-format archive; -- a successful isolated restore drill using the PostgreSQL 18 client/server; +- a successful isolated restore drill using the PostgreSQL 19 client/server; - a separately protected globals export and an inventory of extensions; - measured rollback time within the four-hour RTO; and - a filesystem-level snapshot of the PostgreSQL 16 data directory retained - unchanged until the PostgreSQL 18 validation window closes. + unchanged until the PostgreSQL 19 validation window closes. ## Cutover outline @@ -27,7 +28,7 @@ stopping writers, require all of the following: path. Never overwrite or delete it during the cutover. 4. Create a new empty directory at the configured data path with the existing PostgreSQL uid/gid and mode, then run the major-version preflight. -5. Start the pinned PostgreSQL 18 image, restore reviewed globals and all +5. Start the pinned PostgreSQL 19 image, restore reviewed globals and all database archives, and re-run every idempotent application bootstrap. 6. Run ownership, grants, RLS isolation, migration checksum, TLS/HBA, backup, application smoke, and latency checks before enabling writers. diff --git a/envs/production/compose.yml b/envs/production/compose.yml index 7db9d9b..ae33287 100644 --- a/envs/production/compose.yml +++ b/envs/production/compose.yml @@ -45,7 +45,7 @@ services: memory: ${MAKEPAD_POSTGRES_MEMORY_RESERVATION:-512M} runtrace_backup: - image: ${POSTGRES_IMAGE:-postgres:18-alpine@sha256:0115267ab5a509022df9319c77be365cef335adb71556c75f60f5360ee247e71} + image: ${POSTGRES_IMAGE:-postgres:19-alpine@sha256:cac45fb483caee3668946088a1c0532db89d5285c28dbfeac889b4068296e06f} user: "70:70" command: - /usr/local/bin/run-runtrace-backup-loop.sh diff --git a/scripts/preflight-postgres-major.sh b/scripts/preflight-postgres-major.sh index 3b24812..f7d4dd8 100755 --- a/scripts/preflight-postgres-major.sh +++ b/scripts/preflight-postgres-major.sh @@ -2,7 +2,7 @@ set -euo pipefail data_path=${1:?Usage: preflight-postgres-major.sh [expected-major]} -expected_major=${2:-18} +expected_major=${2:-19} if [[ "${data_path}" != /* || "${data_path}" == / || "${data_path}" == /var || "${data_path}" == /var/lib ]]; then echo "PostgreSQL data path must be a narrow absolute path." >&2 @@ -38,6 +38,6 @@ fi actual_major=$(tr -d '[:space:]' < "${version_file}") if [[ "${actual_major}" != "${expected_major}" ]]; then - echo "Refusing PostgreSQL ${expected_major} against data initialized by PostgreSQL ${actual_major}. Complete docs/postgresql-18-upgrade.md first." >&2 + echo "Refusing PostgreSQL ${expected_major} against data initialized by PostgreSQL ${actual_major}. Complete docs/postgresql-19-upgrade.md first." >&2 exit 1 fi diff --git a/scripts/test-betacrew-encrypted-restore.py b/scripts/test-betacrew-encrypted-restore.py index ddbc7df..310b15d 100644 --- a/scripts/test-betacrew-encrypted-restore.py +++ b/scripts/test-betacrew-encrypted-restore.py @@ -7,7 +7,7 @@ import uuid SCRIPTS=Path(__file__).resolve().parent -IMAGE='postgres@sha256:721873c34ceb9f8d8fc265984940dc982404c105f19ad51be9fdc5970a6080ea' +IMAGE=os.environ.get('POSTGRES_TEST_IMAGE', 'postgres@sha256:721873c34ceb9f8d8fc265984940dc982404c105f19ad51be9fdc5970a6080ea') container='betacrew-encrypted-test-'+uuid.uuid4().hex[:10] def run(*args, **kw): @@ -32,7 +32,7 @@ def run(*args, **kw): def sql(database,query): return run('docker','exec','-i',container,'psql','-U','postgres','-d',database,'-XAt','-v','ON_ERROR_STOP=1',input=query) try: - run('docker','run','-d','--network','none','--name',container,'--tmpfs','/var/lib/postgresql/data','--volume',tmp+':'+tmp,'-e','POSTGRES_PASSWORD=disposable-fixture-password',IMAGE) + run('docker','run','-d','--network','none','--name',container,'--tmpfs','/var/lib/postgresql/data','--volume',tmp+':'+tmp,'-e','PGDATA=/var/lib/postgresql/data','-e','POSTGRES_PASSWORD=disposable-fixture-password',IMAGE) for _ in range(30): if subprocess.run(['docker','exec',container,'pg_isready','-U','postgres'],capture_output=True).returncode==0:break time.sleep(1) diff --git a/scripts/test-jotwink-encrypted-restore.py b/scripts/test-jotwink-encrypted-restore.py index 669a1e5..fccc23c 100644 --- a/scripts/test-jotwink-encrypted-restore.py +++ b/scripts/test-jotwink-encrypted-restore.py @@ -7,7 +7,7 @@ import uuid SCRIPTS=Path(__file__).resolve().parent -IMAGE='postgres@sha256:721873c34ceb9f8d8fc265984940dc982404c105f19ad51be9fdc5970a6080ea' +IMAGE=os.environ.get('POSTGRES_TEST_IMAGE', 'postgres@sha256:721873c34ceb9f8d8fc265984940dc982404c105f19ad51be9fdc5970a6080ea') container='jotwink-encrypted-test-'+uuid.uuid4().hex[:10] def run(*args, **kw): @@ -32,7 +32,7 @@ def run(*args, **kw): def sql(database,query): return run('docker','exec','-i',container,'psql','-U','postgres','-d',database,'-XAt','-v','ON_ERROR_STOP=1',input=query) try: - run('docker','run','-d','--network','none','--name',container,'--tmpfs','/var/lib/postgresql/data','--volume',tmp+':'+tmp,'-e','POSTGRES_PASSWORD=disposable-fixture-password',IMAGE) + run('docker','run','-d','--network','none','--name',container,'--tmpfs','/var/lib/postgresql/data','--volume',tmp+':'+tmp,'-e','PGDATA=/var/lib/postgresql/data','-e','POSTGRES_PASSWORD=disposable-fixture-password',IMAGE) for _ in range(30): if subprocess.run(['docker','exec',container,'pg_isready','-U','postgres'],capture_output=True).returncode==0:break time.sleep(1) diff --git a/scripts/test-postgres-fallback-pins.py b/scripts/test-postgres-fallback-pins.py index 40023b6..ca25f29 100644 --- a/scripts/test-postgres-fallback-pins.py +++ b/scripts/test-postgres-fallback-pins.py @@ -26,7 +26,7 @@ def test_host_fallback_digest_drift_is_rejected(self): path = self.root / 'compose.host.yml' text = path.read_text() import re - text, count = re.subn(r'postgres:18-alpine@sha256:[0-9a-f]{64}', 'postgres:18-alpine@sha256:' + '0' * 64, text, count=1) + text, count = re.subn(r'postgres:19-alpine@sha256:[0-9a-f]{64}', 'postgres:19-alpine@sha256:' + '0' * 64, text, count=1) self.assertEqual(count, 1) path.write_text(text) result = self.validate() @@ -35,7 +35,7 @@ def test_host_fallback_digest_drift_is_rejected(self): def test_production_major_override_change_is_rejected(self): path = self.root / 'envs/production/.env.db' - path.write_text(path.read_text().replace('POSTGRES_IMAGE=postgres:16-alpine@', 'POSTGRES_IMAGE=postgres:18-alpine@')) + path.write_text(path.read_text().replace('POSTGRES_IMAGE=postgres:16-alpine@', 'POSTGRES_IMAGE=postgres:19-alpine@')) result = self.validate() self.assertNotEqual(result.returncode, 0) self.assertIn('must pin POSTGRES_IMAGE', result.stdout + result.stderr) diff --git a/scripts/test-postgres-major-compat.sh b/scripts/test-postgres-major-compat.sh index 835e2d0..39fa9aa 100755 --- a/scripts/test-postgres-major-compat.sh +++ b/scripts/test-postgres-major-compat.sh @@ -5,13 +5,13 @@ cd "$(dirname "$0")/.." old_image=$(sed -n 's/^POSTGRES_IMAGE=//p' envs/production/.env.db) new_image=$(sed -n 's/.*POSTGRES_IMAGE:-\([^}]*\)}.*/\1/p' compose.yml | head -1) data_path=$(sed -n 's/^ PGDATA: //p' compose.yml) -[[ "$old_image" == postgres:16-alpine@sha256:* && "$new_image" == postgres:18-alpine@sha256:* ]] +[[ "$old_image" == postgres:16-alpine@sha256:* && "$new_image" == postgres:19-alpine@sha256:* ]] prefix="postgres-major-review-$$-${RANDOM}" legacy="${prefix}-legacy" candidate="${prefix}-candidate" probe="${prefix}-probe" old_volume="${prefix}-16" -new_volume="${prefix}-18" +new_volume="${prefix}-19" cleanup() { docker rm -fv "$legacy" "$candidate" "$probe" >/dev/null 2>&1 || true docker volume rm "$old_volume" "$new_volume" >/dev/null 2>&1 || true @@ -48,7 +48,7 @@ docker run -d --name "$candidate" --network none --memory 256m \ -e POSTGRES_HOST_AUTH_METHOD=trust "${data_args[@]}" \ -v "$new_volume:/var/lib/postgresql/data" "$new_image" >/dev/null ready "$candidate" -[[ $(docker exec "$candidate" cat /var/lib/postgresql/data/PG_VERSION) == 18 ]] +[[ $(docker exec "$candidate" cat /var/lib/postgresql/data/PG_VERSION) == 19 ]] docker exec "$candidate" createdb -U postgres compatibility docker exec "$legacy" pg_dump -U postgres -Fc compatibility | docker exec -i "$candidate" pg_restore -U postgres -d compatibility --exit-on-error @@ -72,4 +72,4 @@ docker start "$legacy" >/dev/null ready "$legacy" [[ $(docker exec "$legacy" psql -U postgres -d compatibility -Atc "$query") == "$expected" ]] [[ $(docker exec "$legacy" cat /var/lib/postgresql/data/PG_VERSION) == 16 ]] -printf '%s\n' 'PASS: fresh 18 uses the mounted directory, logical 16-to-18 restore preserves rows, and an in-place major swap refuses safely while 16 can restart.' +printf '%s\n' 'PASS: fresh 19 uses the mounted directory, logical 16-to-19 restore preserves rows, and an in-place major swap refuses safely while 16 can restart.' diff --git a/scripts/validate-postgres-config.sh b/scripts/validate-postgres-config.sh index 472df59..d46507f 100755 --- a/scripts/validate-postgres-config.sh +++ b/scripts/validate-postgres-config.sh @@ -227,14 +227,14 @@ for required in ( require("<<'EOF'" not in manual_deploy_workflow, "Manual deploy workflow must not embed the oversized remote deployment heredoc.") require("DEPLOY_BRIO_STAGING_DB_NETWORK must be makepad_brio_staging_db" in manual_deploy, "Manual deploy must reject a non-canonical Brio database network secret.") require("Brio deployment bundle must use makepad_brio_staging_db" in manual_deploy, "Remote deploy must revalidate the canonical Brio database network.") -require("postgres:18-alpine@sha256:" in base_compose, "Base Compose must pin the PostgreSQL 18 default to an immutable digest.") +require("postgres:19-alpine@sha256:" in base_compose, "Base Compose must pin the PostgreSQL 19 default to an immutable digest.") fallback_images = [] for label, content, expected_count in ( ("base", base_compose, 1), ("host", host_compose, 2), ("production", production_compose, 1), ): - images = re.findall(r"\$\{POSTGRES_IMAGE:-(postgres:18-alpine@sha256:[0-9a-f]{64})\}", content) + images = re.findall(r"\$\{POSTGRES_IMAGE:-(postgres:19-alpine@sha256:[0-9a-f]{64})\}", content) require(len(images) == expected_count, f"{label} Compose must retain every immutable PostgreSQL fallback image.") fallback_images.extend(images) require(len(set(fallback_images)) == 1, "PostgreSQL fallback image digests must match across Compose entry points and backup services.")