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 <mchristi@redhat.com>
pull/2954/head
Mike Christie 2018-07-26 13:52:44 -05:00 committed by Sébastien Han
parent d572a9a602
commit 6f72f96dad
2 changed files with 16 additions and 14 deletions

View File

@ -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):

View File

@ -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):