feat: release the target claim in cleanup
cleanup now deletes the claim file under .cephmig/claims as its last step, if it holds the job's own ID, and removes the claim directories when they are empty. A cleaned-up job is finished: cleanup and finalize do nothing and do not claim the target again, and sync is refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5f29328932
commit
a6e7bbb17e
10 files changed
+218
-14
No files matched your search
+10
-2
@@ -29,6 +29,11 @@ def snapshot(cluster, *args):
|
||||
return volume(cluster, "snapshot", *args)
|
||||
|
||||
|
||||
def claim_path():
|
||||
claim = hashlib.sha256("\0".join([ceph("target", "fsid"), "cephfs", "migration", name]).encode()).hexdigest()
|
||||
return "/mnt/target-fs/.cephmig/claims/" + claim
|
||||
|
||||
|
||||
def snapshot_names(cluster):
|
||||
return {x["name"] for x in json.loads(snapshot(cluster, "ls", "cephfs", name))}
|
||||
|
||||
@@ -297,6 +302,7 @@ elif action == "cleaned":
|
||||
assert application == {"history-1", "history-2"}, application
|
||||
for c in ("source", "target"):
|
||||
assert snapshot_names(c) == application, (c, snapshot_names(c))
|
||||
assert not os.path.exists(claim_path()), "claim not released"
|
||||
print(json.dumps({"remaining_snapshots": sorted(application)}))
|
||||
elif action == "busy":
|
||||
# An unrelated source subvolume remains writable throughout migration/finalization.
|
||||
@@ -318,8 +324,10 @@ elif action == "cleanup":
|
||||
for snap in json.loads(snapshot(cluster, "ls", "cephfs", name)):
|
||||
snapshot(cluster, "rm", "cephfs", name, snap["name"])
|
||||
volume(cluster, "rm", "cephfs", name, "--force")
|
||||
claim = hashlib.sha256("\0".join([ceph("target", "fsid"), "cephfs", "migration", name]).encode()).hexdigest()
|
||||
os.unlink("/mnt/target-fs/.cephmig/claims/" + claim)
|
||||
try:
|
||||
os.unlink(claim_path())
|
||||
except FileNotFoundError:
|
||||
pass # cleanup released it
|
||||
shutil.rmtree(work)
|
||||
else:
|
||||
raise ValueError(action)
|
||||
Reference in new issue
Block a user