backup: fix storage-backup oneshot falsely failing on success #212
Inga granskare
Etiketter
Inga etiketter
area/backups
area/ci
area/control-panel
area/identity
area/infra
area/observability
area/payments
area/security
area/storage
area/web
blocked
needs-info
needs-triage
ready-for-implementation
type
bug
type
chore
type
docs
type
epic
type
feature
type
task
wontfix
Ingen milstolpe
Inget projekt
Inga tilldelade
1 deltagare
Notiser
Förfallodatum
Inget förfallodatum satt.
Beroenden
Inga beroenden satta
Referens
bitborg/bitborg-infra!212
Läser in…
Hänvisa till i nytt ärende
Ingen beskrivning angiven.
Ta bort grenen "fix/backup-storage-exit-status"
Borttagning av en gren är permanent. Även om den borttagna grenen kan fortsätta existera en kort tid innan den faktiskt tas bort, kan det INTE ångras i de flesta fall. Vill du fortsätta?
Problem
bitborg-backup-storage.serviceexits non-zero (systemdfailed) even when the restic backupfully succeeds. The
cleanupEXIT trap's only command is[ "${rc}" -ne 0 ] && write_status 1;on the success path (
rc=0) the test is false → the compound returns 1, and as the trap's lastcommand it becomes the script's exit status. So the oneshot is marked failed on every good run.
Observed on the first production run:
snapshot ... saved(8.9 GiB) and the success metricgitborg_backup_storage_last_run_status=0were both written, yet the unit reportedResult=exit-code/status=1/FAILURE. (The daily backup script avoids this only because its traphas later commands that return 0 on the success path.)
Fix
Guard the metric write in an
ifblock andexit "${rc}"explicitly at the end of the trap, so theoneshot's exit status matches reality — 0 on success, the real non-zero on a genuine failure. The
node-exporter metric still drives alerting either way.
Impact
corrects the reported service status.