fix: a cleanup that deletes nothing, and a difference nobody can date #35
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/restore-test-cleanup"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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, whichjq -ereports 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.
3168781db48f3e80bd7e