Compare commits

...

2 Commits

Author SHA1 Message Date
Joshua Boniface 109000c17c Ensure snapshots are removed if none succeed
Avoids having lingering automirror snapshots that will never be cleaned
up.
2024-11-15 12:00:31 -05:00
Joshua Boniface ba4349d289 Fix issues if one is disabled 2024-11-15 11:53:26 -05:00
2 changed files with 14 additions and 3 deletions

View File

@ -389,6 +389,7 @@ def worker_cluster_automirror(
continue
remote_marked_for_deletion = dict()
all_results = list()
for destination in vm_destinations:
mirror_start = datetime.now()
result, ret = run_vm_mirror(
@ -401,6 +402,7 @@ def worker_cluster_automirror(
)
mirror_end = datetime.now()
runtime_secs = (mirror_end - mirror_start).seconds
all_results.append(result)
if result:
remote_marked_for_deletion[destination] = ret
@ -421,6 +423,15 @@ def worker_cluster_automirror(
"result_message": ret,
}
# If all sends failed, remove the snapshot we created as it will never be needed or automatically cleaned up later
if all(not b for b in all_results):
vm.vm_worker_remove_snapshot(
zkhandler,
None,
vm_detail["name"],
snapshot_name,
)
# Find all local snapshots that were present in all remote snapshot deletions,
# then remove them
# If one of the sends fails, this should result in nothing being removed

View File

@ -3446,9 +3446,9 @@ def vm_worker_send_snapshot(
new_tags = list()
for tag in vm_detail["tags"]:
tag_base = tag["name"].split(":")[0]
if tag_base in [t for t in autobackup_config["backup_tags"]] or tag_base in [
t for t in automirror_config["mirror_tags"]
]:
if tag_base in [
t for t in autobackup_config.get("backup_tags", [])
] or tag_base in [t for t in automirror_config.get("mirror_tags", [])]:
continue
new_tags.append(tag)
vm_detail["tags"] = new_tags