From f463e860c481a2b2e0f3a74d4f5643c08690ed45 Mon Sep 17 00:00:00 2001 From: Crispy1975 <12525875+Crispy1975@users.noreply.github.com> Date: Sat, 11 Jul 2026 08:59:49 +0100 Subject: [PATCH] feat(wal-g): install wal-g 3.0.8 alongside v2 (INDATA-904) Adds a wal-g-3 nix package (v3.0.8) built and installed next to wal-g-2. The /usr/local/bin/wal-g symlink stays on v2, so v3 is available as wal-g-3 for backward-compat validation without changing the default. wal-g 3.x imports encoding/json/v2 directly, so the build needs GOEXPERIMENT=jsonv2 under Go 1.25 (threaded through walGCommon as a per-package goExperiment knob; v2 unaffected). --- .../files/postgresql_config/sbpostgres_apparmor | 2 ++ ansible/tasks/setup-wal-g.yml | 7 +++++++ nix/checks.nix | 1 + nix/packages/default.nix | 2 +- nix/packages/wal-g.nix | 17 +++++++++++++++++ testinfra/test_ami_nix.py | 16 +++++++++------- 6 files changed, 37 insertions(+), 8 deletions(-) diff --git a/ansible/files/postgresql_config/sbpostgres_apparmor b/ansible/files/postgresql_config/sbpostgres_apparmor index af35e9bb59..ea59999849 100644 --- a/ansible/files/postgresql_config/sbpostgres_apparmor +++ b/ansible/files/postgresql_config/sbpostgres_apparmor @@ -66,6 +66,7 @@ profile sbpostgres flags=(attach_disconnected) { /bin/cat Pix -> postgres_shell, /usr/bin/admin-mgr Pix -> postgres_shell, /nix/store/*/bin/wal-g-2 Pix -> postgres_shell, + /nix/store/*/bin/wal-g-3 Pix -> postgres_shell, /nix/store/*/bin/pgbackrest Pix -> postgres_shell, /nix/store/*/bin/pg_dump ix, /usr/bin/pgbackrest Pix -> pgbackrest_shell, @@ -107,6 +108,7 @@ profile sbpostgres flags=(attach_disconnected) { /opt/supabase-admin-agent/supabase-admin-agent-linux-amd64 ix, /nix/store/*/bin/.postgres-wrapped ix, /nix/store/*/bin/wal-g-2 ix, + /nix/store/*/bin/wal-g-3 ix, /nix/store/*/bin/pgbackrest ix, /nix/store/*/bin/pg_dump ix, /nix/store/*/bin/pg_archivecleanup ix, diff --git a/ansible/tasks/setup-wal-g.yml b/ansible/tasks/setup-wal-g.yml index 0d923cd05d..16379b5083 100644 --- a/ansible/tasks/setup-wal-g.yml +++ b/ansible/tasks/setup-wal-g.yml @@ -33,6 +33,13 @@ cmd: sudo -u wal-g bash -c ". /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh && nix profile install github:supabase/postgres/{{ git_commit_sha }}#wal-g-2" become: true + # Installed alongside v2 (INDATA-904). The /usr/local/bin/wal-g symlink below + # still points at v2, so v3 is available (as wal-g-3) but not yet the default. + - name: Install wal-g 3 from nix binary cache + ansible.builtin.shell: + cmd: sudo -u wal-g bash -c ". /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh && nix profile install github:supabase/postgres/{{ git_commit_sha }}#wal-g-3" + become: true + - name: nix collect garbage ansible.builtin.shell: cmd: sudo -u ubuntu bash -c ". /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh && nix-collect-garbage -d" diff --git a/nix/checks.nix b/nix/checks.nix index b328ccb2cf..05d78f84e2 100644 --- a/nix/checks.nix +++ b/nix/checks.nix @@ -932,6 +932,7 @@ supabase-cli supascan wal-g-2 + wal-g-3 ; devShell = self'.devShells.default; } diff --git a/nix/packages/default.nix b/nix/packages/default.nix index a452a9b784..a8df80b26b 100644 --- a/nix/packages/default.nix +++ b/nix/packages/default.nix @@ -113,7 +113,7 @@ inherit (pkgs) yq; postgresql_15 = self'.packages."postgresql_15"; }; - inherit (pkgs.callPackage ./wal-g.nix { }) wal-g-2; + inherit (pkgs.callPackage ./wal-g.nix { }) wal-g-2 wal-g-3; inherit (supascan-pkgs) goss supascan supascan-specs; inherit (pg-startup-profiler-pkgs) pg-startup-profiler; inherit (pkgs.cargo-pgrx) diff --git a/nix/packages/wal-g.nix b/nix/packages/wal-g.nix index 07e6eb5720..a18cffb708 100644 --- a/nix/packages/wal-g.nix +++ b/nix/packages/wal-g.nix @@ -14,6 +14,9 @@ let vendorHash, sha256, majorVersion, + # Extra GOEXPERIMENT flags. wal-g 3.x imports encoding/json/v2 directly + # (internal/uploader.go), which Go 1.25 gates behind GOEXPERIMENT=jsonv2. + goExperiment ? null, }: buildGoModule rec { pname = "wal-g-${majorVersion}"; @@ -28,6 +31,10 @@ let inherit vendorHash; + env = lib.optionalAttrs (goExperiment != null) { + GOEXPERIMENT = goExperiment; + }; + nativeBuildInputs = [ installShellFiles ]; buildInputs = [ @@ -77,4 +84,14 @@ in vendorHash = "sha256-BbQuY6r30AkxlCZjY8JizaOrqEBdv7rIQet9KQwYB/g="; majorVersion = "2"; }; + + # wal-g v3.0.8 — installed alongside v2 (INDATA-904). + # OrioleDB support + backward-compat validation; binary is wal-g-3. + wal-g-3 = walGCommon { + version = "3.0.8"; + sha256 = "sha256-iDLC3Td/U1msqdpUbJWS+MBDznx7NbddGWFP4rrfSus="; + vendorHash = "sha256-K2J/Hi8TQs+UhudgTWsAmPUHKnwKP3cmx21CvDTjs6M="; + majorVersion = "3"; + goExperiment = "jsonv2"; + }; } diff --git a/testinfra/test_ami_nix.py b/testinfra/test_ami_nix.py index 084512e3de..cc67f59a94 100644 --- a/testinfra/test_ami_nix.py +++ b/testinfra/test_ami_nix.py @@ -1171,19 +1171,21 @@ def test_apparmor_allows_pg_dump(host): ) -def test_apparmor_allows_walg(host): - """Verify wal-g-2 can be executed under the sbpostgres AppArmor profile. +@pytest.mark.parametrize("walg_binary", ["wal-g-2", "wal-g-3"]) +def test_apparmor_allows_walg(host, walg_binary): + """Verify wal-g-2 and wal-g-3 can be executed under the sbpostgres AppArmor profile. - /nix/store/*/bin/wal-g-2 is listed as 'ix' in postgres_shell. We locate the - binary at runtime since the Nix store hash is not known ahead of time. + /nix/store/*/bin/wal-g-2 and /nix/store/*/bin/wal-g-3 are listed as 'ix' in + postgres_shell. We locate the binary at runtime since the Nix store hash is + not known ahead of time. """ find_result = run_ssh_command( host["ssh"], - "find /nix/store -maxdepth 3 -name 'wal-g-2' -type f 2>/dev/null | head -1", + f"find /nix/store -maxdepth 3 -name '{walg_binary}' -type f 2>/dev/null | head -1", ) walg_path = find_result["stdout"].strip() if not walg_path: - print("wal-g-2 not found in Nix store, skipping") + print(f"{walg_binary} not found in Nix store, skipping") return result = run_ssh_command( @@ -1192,7 +1194,7 @@ def test_apparmor_allows_walg(host): f"\"COPY (SELECT 1) TO PROGRAM '{walg_path} --version';\"", ) assert result["succeeded"], ( - f"wal-g-2 was blocked by AppArmor.\n" + f"{walg_binary} was blocked by AppArmor.\n" f"stdout: {result['stdout']}\nstderr: {result['stderr']}" )