feat: remove cephmig snapshots during sync and add cleanup command
Users of a subvolume should not see traces of the migration. Each sync round now deletes the older cephmig-* round snapshots at source and target and keeps only the newest one as base for the next round. The new command `cephmig cleanup` deletes the remaining one after the cutover. Application snapshots are never touched. The journal marks a snapshot as removed before deleting it, so an interrupted run finishes the deletion instead of reporting a vanished snapshot. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
cc2dff46a0
commit
907d400765
9 files changed
+322
-19
No files matched your search
@@ -209,6 +209,12 @@ for snap in history-1 history-2; do
|
||||
test "$a" = "$b"
|
||||
done
|
||||
python3 /lab/snapshot-identity.py --config "$config" --snapshot history-1
|
||||
"$binary" cleanup --config "$config" --state "$state" > "$work/cleaned.json"
|
||||
for side in source_ceph target_ceph; do
|
||||
names=$("$side" fs subvolume snapshot ls cephfs "$name" --group_name migration |
|
||||
python3 -c 'import json,sys; print(" ".join(sorted(x["name"] for x in json.load(sys.stdin))))')
|
||||
test "$names" = "history-1 history-2"
|
||||
done
|
||||
completed=true
|
||||
echo 'PASS: Go migration, historical snapshots, live catch-up, quotas, ACLs, xattrs, sparse-file contents, crash/error resume, exclusive target, finalization'
|
||||
echo 'PASS: Go migration, historical snapshots, live catch-up, quotas, ACLs, xattrs, sparse-file contents, crash/error resume, exclusive target, finalization, snapshot cleanup'
|
||||
|
||||
@@ -29,6 +29,10 @@ def snapshot(cluster, *args):
|
||||
return volume(cluster, "snapshot", *args)
|
||||
|
||||
|
||||
def snapshot_names(cluster):
|
||||
return {x["name"] for x in json.loads(snapshot(cluster, "ls", "cephfs", name))}
|
||||
|
||||
|
||||
def acl():
|
||||
entries = [(1, 6, 0xffffffff), (2, 4, 12345), (4, 0, 0xffffffff),
|
||||
(16, 4, 0xffffffff), (32, 0, 0xffffffff)]
|
||||
@@ -247,8 +251,16 @@ elif action in ("verify", "final"):
|
||||
compare(roots["source"], roots["target"])
|
||||
compare_times(roots["source"], roots["target"], atime=False)
|
||||
s = json.load(open(state))
|
||||
listed = {c: snapshot_names(c) for c in ("source", "target")}
|
||||
# Only the newest round snapshot remains as base; older ones are removed.
|
||||
kept = [x["name"] for x in s["snapshots"] if x["owned"] and not x.get("removed")]
|
||||
assert kept == [s["live_snapshot"]], (kept, s["live_snapshot"])
|
||||
for c in ("source", "target"):
|
||||
assert {n for n in listed[c] if n.startswith("cephmig-")} == set(kept), (c, listed[c])
|
||||
for snap in s["snapshots"]:
|
||||
assert snap["done"], snap
|
||||
if snap.get("removed"):
|
||||
continue
|
||||
a, b = [f"/mnt/{c}-fs" + ceph(c, "fs", "subvolume", "snapshot", "getpath",
|
||||
"cephfs", name, snap["name"], "migration") for c in ("source", "target")]
|
||||
compare(a, b)
|
||||
@@ -264,6 +276,18 @@ elif action in ("verify", "final"):
|
||||
assert s["phase"] == "ready-for-cutover" and len(s["snapshots"]) == 5, s
|
||||
assert s["snapshots"][-1]["transfer"]["bytes_copied"] == 0, s["snapshots"][-1]
|
||||
print(json.dumps({"phase": s["phase"], "rounds": len(s["snapshots"]), "history_2": h2}))
|
||||
elif action == "cleaned":
|
||||
roots = json.load(open(fixture))
|
||||
compare(roots["source"], roots["target"])
|
||||
compare_times(roots["source"], roots["target"], atime=False)
|
||||
s = json.load(open(state))
|
||||
assert s["phase"] == "ready-for-cutover" and not s.get("live_snapshot"), s
|
||||
assert all(x.get("removed") for x in s["snapshots"] if x["owned"]), s
|
||||
application = {x["name"] for x in s["snapshots"] if not x["owned"]}
|
||||
assert application == {"history-1", "history-2"}, application
|
||||
for c in ("source", "target"):
|
||||
assert snapshot_names(c) == application, (c, snapshot_names(c))
|
||||
print(json.dumps({"remaining_snapshots": sorted(application)}))
|
||||
elif action == "busy":
|
||||
# An unrelated source subvolume remains writable throughout migration/finalization.
|
||||
p = "/mnt/source/" + name
|
||||
|
||||
+5
-1
@@ -90,5 +90,9 @@ assert json.loads((p/"before.json").read_text()) == json.loads((p/"idempotent.js
|
||||
assert int((p/"busy-count").read_text()) > int((p/"busy-before-final").read_text()) > 20
|
||||
PY
|
||||
SH
|
||||
# Remove all cephmig snapshots; a second run must find nothing left to do.
|
||||
"${compose[@]}" exec -T native "$binary" cleanup --config "$config" --state "$state"
|
||||
"${compose[@]}" exec -T native "$binary" cleanup --config "$config" --state "$state"
|
||||
fixture cleaned "$name"
|
||||
completed=true
|
||||
echo 'PASS: native libcephfs without FUSE/rsync, blockdiff, snapshots, links, ACLs, xattrs, quotas, cancellation, SIGKILL resume, unrelated writers, finalization'
|
||||
echo 'PASS: native libcephfs without FUSE/rsync, blockdiff, snapshots, links, ACLs, xattrs, quotas, cancellation, SIGKILL resume, unrelated writers, finalization, snapshot cleanup'
|
||||
Reference in new issue
Block a user