pithead robustness: backup degrades gracefully on du/df errors; doctor exits non-zero on FAIL (#127)#148
Merged
Merged
Conversation
…-zero on FAIL (#127) backup: the disk-space pre-check assigned `need_kb`/`avail_kb` as bare statements, so a non-zero `du` exit (an unreadable subdir, a vanished file, an NFS hiccup) tripped errexit and aborted the whole backup — making the "proceeding without a space check" fallback unreachable. Add `|| true` so it degrades as intended. doctor: it tallied DR_FAIL but always `return 0`, and the dispatch didn't propagate, so `pithead doctor` always exited 0 — useless as a cron/CI/monitoring health gate. Return 1 when DR_FAIL>0 and dispatch via `doctor || exit 1` (mirrors `status`); warnings still exit 0. Adds a black-box test driving a critical FAIL via an unreachable daemon stub, asserting doctor runs to its summary and exits 1. CHANGELOG updated. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two small, independent
pitheaderror-handling fixes from the v1.0 sweep.backupaborted on a non-fataldu/dferrorThe disk-space pre-check assigned
need_kb/avail_kbas bare statements:Under
set -Eeuo pipefail+trap on_err ERR,duexiting non-zero (a permission-denied subdir, a file vanishing mid-walk, an NFS hiccup — even though2>/dev/nullhides it and a total is still printed) tripped errexit and aborted the whole backup with the generic "aborted unexpectedly" — leaving the carefully-written "proceeding without a space check" fallback unreachable. Adding|| trueto both assignments lets it degrade as designed.doctoralways exited 0, even on critical FAILdoctortalliedDR_FAILfor hard failures (missingjq/openssl/docker, unreachable daemon) but unconditionallyreturn 0, and the dispatch wasdoctor) doctor ;;with no propagation — sopithead doctor; echo $?was always 0, making it useless as a cron/CI/monitoring health gate. Now itreturn 1whenDR_FAIL>0and dispatches viadoctor || exit 1(mirroringstatus). Warnings alone still exit 0.Tests
Adds a black-box test (
tests/stack/run.sh) that drives a single critical failure via an unreachable-daemon docker stub and assertsdoctorruns to its summary (so the exit 1 is from the FAIL tally, not an early crash) and exits 1. Suite: 94 passed, shellcheck clean.(A backup round-trip test is deferred to #140, which scopes comprehensive backup/restore + doctor coverage.)
Closes #127.
🤖 Generated with Claude Code