Add RBD snap purge during volume removal

Fixes #180
This commit is contained in:
Joshua Boniface 2024-04-19 10:31:11 -04:00
parent 9714ac20b2
commit ab944f9b95
1 changed files with 13 additions and 1 deletions

View File

@ -828,10 +828,22 @@ def remove_volume(zkhandler, pool, name):
name, pool name, pool
) )
# 1. Remove volume snapshots # 1a. Remove PVC-managed volume snapshots
for snapshot in zkhandler.children(("snapshot", f"{pool}/{name}")): for snapshot in zkhandler.children(("snapshot", f"{pool}/{name}")):
remove_snapshot(zkhandler, pool, name, snapshot) remove_snapshot(zkhandler, pool, name, snapshot)
# 1b. Purge any remaining volume snapshots
retcode, stdout, stderr = common.run_os_command(
"rbd snap purge {}/{}".format(pool, name)
)
if retcode:
return (
False,
'ERROR: Failed to purge snapshots from RBD volume "{}" in pool "{}": {}'.format(
name, pool, stderr
),
)
# 2. Remove the volume # 2. Remove the volume
retcode, stdout, stderr = common.run_os_command("rbd rm {}/{}".format(pool, name)) retcode, stdout, stderr = common.run_os_command("rbd rm {}/{}".format(pool, name))
if retcode: if retcode: