From ab944f9b955f0501c0bfbc1c1c9381f2a7349f1e Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Fri, 19 Apr 2024 10:31:11 -0400 Subject: [PATCH] Add RBD snap purge during volume removal Fixes #180 --- daemon-common/ceph.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/daemon-common/ceph.py b/daemon-common/ceph.py index 3609fa54..ab7e8db6 100644 --- a/daemon-common/ceph.py +++ b/daemon-common/ceph.py @@ -828,10 +828,22 @@ def remove_volume(zkhandler, pool, name): name, pool ) - # 1. Remove volume snapshots + # 1a. Remove PVC-managed volume snapshots for snapshot in zkhandler.children(("snapshot", f"{pool}/{name}")): 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 retcode, stdout, stderr = common.run_os_command("rbd rm {}/{}".format(pool, name)) if retcode: