From 6f72f96dadb7b38f065ccef3f0618a2897f8465f Mon Sep 17 00:00:00 2001 From: Mike Christie Date: Thu, 26 Jul 2018 13:52:44 -0500 Subject: [PATCH] igw: do not fail purge on rbd removal errors Instead of failing the entire purge operation when the rbd command fails just log an error. This will allow the higher level target and config cleanup to complete, and the user only has to manually delete the rbd images. Signed-off-by: Mike Christie --- library/igw_purge.py | 15 ++++++++------- roles/ceph-iscsi-gw/library/igw_purge.py | 15 ++++++++------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/library/igw_purge.py b/library/igw_purge.py index 92e6433a7..4e29ddc47 100644 --- a/library/igw_purge.py +++ b/library/igw_purge.py @@ -55,11 +55,11 @@ def delete_group(module, image_list, cfg): pending_list = list(image_list) for rbd_path in image_list: - if delete_rbd(module, rbd_path): - disk_key = rbd_path.replace('/', '.', 1) - cfg.del_item('disks', disk_key) - pending_list.remove(rbd_path) - cfg.changed = True + delete_rbd(module, rbd_path) + disk_key = rbd_path.replace('/', '.', 1) + cfg.del_item('disks', disk_key) + pending_list.remove(rbd_path) + cfg.changed = True if cfg.changed: cfg.commit() @@ -74,8 +74,9 @@ def delete_rbd(module, rbd_path): rbd_path) rc, rm_out, err = module.run_command(rm_cmd, use_unsafe_shell=True) logger.debug("delete RC = {}, {}".format(rc, rm_out, err)) - - return True if rc == 0 else False + if rc != 0: + logger.error("Could not fully cleanup image {}. Manually run the rbd " + "command line tool to remove.".format(rbd_path)) def is_cleanup_host(config): diff --git a/roles/ceph-iscsi-gw/library/igw_purge.py b/roles/ceph-iscsi-gw/library/igw_purge.py index 92e6433a7..4e29ddc47 100644 --- a/roles/ceph-iscsi-gw/library/igw_purge.py +++ b/roles/ceph-iscsi-gw/library/igw_purge.py @@ -55,11 +55,11 @@ def delete_group(module, image_list, cfg): pending_list = list(image_list) for rbd_path in image_list: - if delete_rbd(module, rbd_path): - disk_key = rbd_path.replace('/', '.', 1) - cfg.del_item('disks', disk_key) - pending_list.remove(rbd_path) - cfg.changed = True + delete_rbd(module, rbd_path) + disk_key = rbd_path.replace('/', '.', 1) + cfg.del_item('disks', disk_key) + pending_list.remove(rbd_path) + cfg.changed = True if cfg.changed: cfg.commit() @@ -74,8 +74,9 @@ def delete_rbd(module, rbd_path): rbd_path) rc, rm_out, err = module.run_command(rm_cmd, use_unsafe_shell=True) logger.debug("delete RC = {}, {}".format(rc, rm_out, err)) - - return True if rc == 0 else False + if rc != 0: + logger.error("Could not fully cleanup image {}. Manually run the rbd " + "command line tool to remove.".format(rbd_path)) def is_cleanup_host(config): -- 2.39.5