Repository navigation
lh-snap-revert: add a Longhorn snapshot revert tool for EVE-K - #7038
andrewd-zededa wants to merge 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7038 +/- ##
==========================================
+ Coverage 30.79% 31.29% +0.49%
==========================================
Files 562 573 +11
Lines 101223 102818 +1595
==========================================
+ Hits 31169 32172 +1003
- Misses 67634 68271 +637
+ Partials 2420 2375 -45 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
35095ab to
893a9dc
Compare
|
Claude finished @rene's task in 3m 56s —— View job Review of PR #7038 —
|
893a9dc to
11de832
Compare
bb7d3a7 to
c468b25
Compare
|
pushed again to resolve spdx issue |
c468b25 to
91ec977
Compare
|
CI notes on the remaining failures:
|
91ec977 to
82a8fb5
Compare
|
Pushed an update to 82a8fb5:
Checked with |
82a8fb5 to
c1923ec
Compare
|
Bumped This only affects the scan. The real binary is still compiled with Go 1.26.10, because both The remaining yetus -1 is a false positive. golangci-lint prints |
Add the go.mod and vendored dependencies for the Longhorn snapshot revert tool, a separate Go module in pkg/kube/lh-snap-revert. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Andrew Durbin <andrewd@zededa.com>
Add an out-of-band recovery tool, for occasional use, that reverts the Longhorn volume behind an EVE-K app PVC to a snapshot in place. The PVC, its UID and the PV do not change. The tool changes only the Longhorn volume and does not manage the app state. Scheduling, retention and backup of snapshots stay with Longhorn and EVE, and stopping the app stays with the controller. The kube image includes it as /usr/bin/lh-snap-revert. It also builds as a standalone binary with "make lh-snap-revert ZARCH=<arch>" for nodes of older releases that run Longhorn v1.9.1. The tool does not scale the app VMIRS, because pillar restores a VMIRS that has 0 replicas. The operator pauses EVE's snapshot schedule with storage.longhorn.snapshot.cron, so that the recurring job does not delete the target snapshot, and stops the app from the controller. The tool refuses to run while the PVC is in use. Longhorn runs recurring jobs on attached volumes, so the tool sets the volume's recurring job labels to disabled for the run and restores them after. It takes a safety-net snapshot, attaches the volume with its own attachment ticket and the frontend disabled, reverts, and releases the volume on exit or failure. The snapshot comes first because the Longhorn v1.9.1 engine crashes on a snapshot while its frontend is disabled. A revert leaves the old snapshots on a branch. Longhorn cannot purge a snapshot with two branches below it and can then keep the volume attached, which blocks a later revert. "list" shows the snapshot tree and "cleanup" deletes the old branch, so that a later revert stays possible. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Andrew Durbin <andrewd@zededa.com>
c1923ec to
1bd631a
Compare
|
rebased for spdx issue |
| pkg/alpine/dnstest/vendor/ | ||
| pkg/kube/stale-mount-cleanup/vendor/ | ||
| pkg/storage-resizer/vendor/ | ||
| pkg/kube/lh-snap-revert/vendor/ |
There was a problem hiding this comment.
@andrewd-zededa , this should be added to Yetus excludes as well (.yetus/excludes.txt)
There was a problem hiding this comment.
.yetus/excludes.txt already has ^.+/vendor/.+, which covers pkg/kube/lh-snap-revert/vendor/, looks like the remaining -1 is the pkg/kube/lh-snap-revert/0 issues. line
Description
Add
lh-snap-revert, an out-of-band recovery tool for occasional use thatreverts the Longhorn volume behind an EVE-K app PVC to a snapshot in place.
The PVC, its UID and the PV do not change, so the app uses the reverted data
when it starts again.
The tool:
revert)list)cleanup)Scheduling, retention and backup of snapshots stay with Longhorn and EVE.
Stopping the app stays with the controller.
The pillar image includes the tool as
/opt/zededa/bin/lh-snap-revertforHV=k. It also builds as a standalone binary with
make lh-snap-revert ZARCH=<arch>, so it can be copied to a node of an olderrelease that runs Longhorn v1.9.1.
Design notes:
has 0 replicas. It refuses to run while the PVC is in use.
storage.longhorn.snapshot.cronon every node, so that the recurring jobdoes not delete the target snapshot during the procedure.
sets the volume's recurring job labels to
disabledand restores themafter.
ticket and the frontend disabled, reverts, and releases the volume on exit
or failure. The snapshot comes first because the Longhorn v1.9.1 engine
crashes on a snapshot while its frontend is disabled.
snapshot with two children and can then keep the volume attached, which
blocks a later revert.
cleanupdeletes that branch.revertwarns and exits unless--ignore-longhorn-versionis passed.The procedure, flags, exit codes and recovery steps are in
pkg/pillar/tools/lh-snap-revert/README.md.How to test and validate this PR
Automated:
go test -race ./tools/lh-snap-revertinpkg/pillarruns therevert flow against a fake Longhorn API, including the v1.9.1 snapshot and
attachment behaviour, preflight refusals, the version override and a
safety-net snapshot that stays pending.
Manual, on a 3-node EVE-K cluster with Longhorn v1.9.1 and an app with a
Longhorn PVC:
storage.longhorn.snapshot.cronto an empty value on every node.Check that
kubectl -n longhorn-system get recurringjobs.longhorn.iodoesnot list
default-eve-kube-app-snapshot.lh-snap-revert pvcs. The USED BY column for the app's PVCmust be
-.lh-snap-revert list --pvc <pvc>and pick the snapshot from step 1.lh-snap-revert revert --pvc <pvc> --snapshot <snap> --dry-run, thenwithout
--dry-run. It must exit 0 and print the safety-net snapshot name.listagain: the old snapshots and the safety-net snapshot show asold branch. Runlh-snap-revert cleanup --pvc <pvc>, andlistmustshow one chain ending in
volume-head.storage.longhorn.snapshot.cronon every node.Tested so far with the standalone binary on a 3-node cluster: the full cycle
above, including the safety-net snapshot and cleanup. Not yet tested: the
pillar-image path (
eve exec pillar /opt/zededa/bin/lh-snap-revert), an appwith several disks, and interrupting a run with Ctrl-C.
make mini-yetuspasses, with only the existing hadolint DL3018 warnings inpkg/pillar/Dockerfile.Changelog notes
EVE-K: add
lh-snap-revert, a recovery tool that reverts an app volume to aLonghorn snapshot in place, and lists and deletes the old snapshot branch
that a revert leaves.
PR Backports
Checklist
I've provided a proper description
I've added the proper documentation
I've tested my PR on amd64 device
I've tested my PR on arm64 device
I've written the test verification instructions
I've set the proper labels to this PR
I've checked the boxes above, or I've provided a good reason why I didn't
check them.
🤖 Generated with Claude Code