]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
igw: do not fail purge on rbd removal errors
authorMike Christie <mchristi@redhat.com>
Thu, 26 Jul 2018 18:52:44 +0000 (13:52 -0500)
committerSébastien Han <seb@redhat.com>
Tue, 31 Jul 2018 08:09:08 +0000 (10:09 +0200)
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>
(cherry picked from commit 6f72f96dadb7b38f065ccef3f0618a2897f8465f)

library/igw_purge.py
roles/ceph-iscsi-gw/library/igw_purge.py

index cffc4f4346aacfa1da3e3e5f1b539cdbad96abb2..1860690ed1c355953f6f948aeb9de9ecc2804479 100644 (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()
@@ -73,8 +73,9 @@ def delete_rbd(module, rbd_path):
     rm_cmd = 'rbd --no-progress rm {}'.format(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):
index cffc4f4346aacfa1da3e3e5f1b539cdbad96abb2..1860690ed1c355953f6f948aeb9de9ecc2804479 100644 (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()
@@ -73,8 +73,9 @@ def delete_rbd(module, rbd_path):
     rm_cmd = 'rbd --no-progress rm {}'.format(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):