postgres-operator icon indicating copy to clipboard operation
postgres-operator copied to clipboard

fix: propagate pgbackrest info failures

Open immanuwell opened this issue 6 months ago • 1 comments

Small fix for pgbackrest_info.sh.

Right now the script prints |, runs pgbackrest info, then always reaches echo. So if pgbackrest exits non-zero, the helper can still look green. sneaky little footgun.

Repro:

printf '#!/bin/sh\nexit 42\n' > /tmp/pgbackrest
chmod +x /tmp/pgbackrest
PATH=/tmp /bin/bash components/image-postgres/bin/pgbackrest-info.sh

Before: exits 0. After: exits 42.

This is reachable in real clusters: pgbackrest info can fail from config/stanza issues, repo storage or network errors, missing binaries in a bad image, or an OOM/signal. No cloud quota edge-case needed here.

Tested:

go test ./components/... -count=1

Related: #3293

immanuwell avatar May 13 '26 17:05 immanuwell

Hi @immanuwell, Thanks for this contributions but this PR needs rebased and updated.

CI failures look mostly mechanical:

vulnerabilities (govulncheck), e2e-k3d-chainsaw, and e2e-k3d-kuttl will all clear with a rebase onto current main — they're all from changes that landed since this PR was opened (x/net v0.54 in #4481, chainsaw/kuttl Go pin revert in #4488). The golangci-lint failure has 2 real gosec G306 hits on the new test file — os.WriteFile with 0o700 perms (gosec wants ≤0o600). Easiest fix is to write 0o600 then os.Chmod(path, 0o700) so the executable bit is set after creation. That keeps the lint config clean. Once you rebase + apply the chmod fix, this should be all green.

ValClarkson avatar May 14 '26 16:05 ValClarkson

@ValClarkson done, addressed all required suggestions, PTAL

immanuwell avatar Jun 28 '26 09:06 immanuwell