Fix bad snapshot removals

This commit is contained in:
Joshua Boniface 2023-10-17 12:02:24 -04:00
parent a8e4b01b67
commit a58c1d5a8c
1 changed files with 5 additions and 8 deletions

View File

@ -1434,7 +1434,7 @@ def backup_vm(
"backup_files": [f".{datestring}/{v}.{export_fileext}" for p, v in vm_volumes], "backup_files": [f".{datestring}/{v}.{export_fileext}" for p, v in vm_volumes],
} }
with open(f"{vm_target_root}/{domain}.{datestring}.pvcbackup", "w") as fh: with open(f"{vm_target_root}/{domain}.{datestring}.pvcbackup", "w") as fh:
jdump(fh, vm_backup) jdump(vm_backup, fh)
# 8. Remove snapshots if retain_snapshot is False # 8. Remove snapshots if retain_snapshot is False
if not retain_snapshots: if not retain_snapshots:
@ -1452,12 +1452,9 @@ def backup_vm(
msg_snapshot_remove_failed.append(retmsg) msg_snapshot_remove_failed.append(retmsg)
if is_snapshot_remove_failed: if is_snapshot_remove_failed:
for pool, volume in vm_volumes: return (
if ceph.verifySnapshot(zkhandler, pool, volume, snapshot_name): True,
ceph.remove_snapshot(zkhandler, pool, volume, snapshot_name) f'WARNING: Successfully backed up VM {domain} @ {datestring} to {target_path}, but failed to remove snapshot as requested for volume(s) {", ".join(which_snapshot_remove_failed)}: {", ".join(msg_snapshot_remove_failed)}',
return ( )
True,
f'WARNING: Successfully backed up VM {domain} @ {datestring} to {target_path}, but failed to remove snapshot as requested for volume(s) {", ".join(which_snapshot_remove_failed)}: {", ".join(msg_snapshot_remove_failed)}',
)
return True, f"Successfully backed up VM {domain} @ {datestring} to {target_path}" return True, f"Successfully backed up VM {domain} @ {datestring} to {target_path}"