fix: a cleanup that deletes nothing, and a difference nobody can date #35

Merged
ivuorinen merged 1 commit from fix/restore-test-cleanup into main 2026-09-21 20:32:25 +00:00
Owner

Two faults found by running the script for real.

cleanup() guarded every delete with kubectl get pod/$POD -l $LABEL, and kubectl refuses that combination outright: 'selectors and the all flag cannot be used when passing resource/name arguments'. Exit 1 for an object that exists and carries the label, so the guard was always false and the script deleted nothing, silently, while its header promised otherwise. The leftovers are not just litter: a test volume carries no recurring-job label, lands in Longhorn's default group, and is backed up nightly from then on. The guard now reads the label off the object, and a missing object gives jq no input, which jq -e reports as no result.

The pod is deleted before the PVC, and that order is load-bearing: pvc-protection holds a PVC in Terminating while any scheduled pod names it, whatever phase that pod is in. A Completed pod is enough. Deleting the PVC first hangs kubectl forever.

The comparison then printed a diff and stopped, leaving the reader to work out by hand whether a difference was a post-snapshot write or a broken restore. It now dates each one: the live file's mtime against the snapshot's. A file deleted since the backup has no mtime left to read and is reported undatable rather than waved through. Verified against busybox:1.37.0 for all four exit paths.

It still exits non-zero on any difference. A tool that decides for itself which differences are harmless is the false pass this script exists to prevent, facing the other way.

Two faults found by running the script for real. cleanup() guarded every delete with `kubectl get pod/$POD -l $LABEL`, and kubectl refuses that combination outright: 'selectors and the all flag cannot be used when passing resource/name arguments'. Exit 1 for an object that exists and carries the label, so the guard was always false and the script deleted nothing, silently, while its header promised otherwise. The leftovers are not just litter: a test volume carries no recurring-job label, lands in Longhorn's default group, and is backed up nightly from then on. The guard now reads the label off the object, and a missing object gives jq no input, which `jq -e` reports as no result. The pod is deleted before the PVC, and that order is load-bearing: pvc-protection holds a PVC in Terminating while any scheduled pod names it, whatever phase that pod is in. A Completed pod is enough. Deleting the PVC first hangs kubectl forever. The comparison then printed a diff and stopped, leaving the reader to work out by hand whether a difference was a post-snapshot write or a broken restore. It now dates each one: the live file's mtime against the snapshot's. A file deleted since the backup has no mtime left to read and is reported undatable rather than waved through. Verified against busybox:1.37.0 for all four exit paths. It still exits non-zero on any difference. A tool that decides for itself which differences are harmless is the false pass this script exists to prevent, facing the other way.
ivuorinen force-pushed fix/restore-test-cleanup from 3168781db4
All checks were successful
validate / hooks (pull_request) Successful in 1m18s
validate / render (pull_request) Successful in 34s
to 8f3e80bd7e
All checks were successful
validate / hooks (pull_request) Successful in 1m10s
validate / render (pull_request) Successful in 32s
2026-09-21 20:27:50 +00:00
Compare
ivuorinen deleted branch fix/restore-test-cleanup 2026-09-21 20:32:25 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ivuorinen/turingpi-cluster!35
No description provided.