Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ansible/files/postgresql_config/sbpostgres_apparmor
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions ansible/tasks/setup-wal-g.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions nix/checks.nix
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,7 @@
supabase-cli
supascan
wal-g-2
wal-g-3
;
devShell = self'.devShells.default;
}
Expand Down
2 changes: 1 addition & 1 deletion nix/packages/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
17 changes: 17 additions & 0 deletions nix/packages/wal-g.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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}";
Expand All @@ -28,6 +31,10 @@ let

inherit vendorHash;

env = lib.optionalAttrs (goExperiment != null) {
GOEXPERIMENT = goExperiment;
};

nativeBuildInputs = [ installShellFiles ];

buildInputs = [
Expand Down Expand Up @@ -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";
};
}
16 changes: 9 additions & 7 deletions testinfra/test_ami_nix.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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']}"
)

Expand Down
Loading