From 20497cf89db778cfa124a1e46b3e463a0348d7ae Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Fri, 3 Nov 2023 02:29:50 -0400 Subject: [PATCH] Fix bugs and skip safe_to_destroy on force --- node-daemon/pvcnoded/objects/CephInstance.py | 30 ++++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/node-daemon/pvcnoded/objects/CephInstance.py b/node-daemon/pvcnoded/objects/CephInstance.py index b02cdede..2c095d35 100644 --- a/node-daemon/pvcnoded/objects/CephInstance.py +++ b/node-daemon/pvcnoded/objects/CephInstance.py @@ -562,10 +562,9 @@ class CephOSDInstance(object): ) # Try to determine if any other OSDs shared a block device with this OSD + _, osd_list = get_list_osd(zkhandler, None) all_osds_on_block = [ - o - for o in get_list_osd(zkhandler, None) - if o["node"] == node and o["device"] == osd_block + o for o in osd_list if o["node"] == node and o["device"] == osd_block ] # Remove each OSD on the block device @@ -596,7 +595,7 @@ class CephOSDInstance(object): f"blockdev --getsize64 {all_osds_on_block[0]['db_device']}" ) osd_db_ratio = None - osd_db_size = f"{osd_db_size}B" + osd_db_size = f"{osd_db_size_bytes}B" else: osd_db_ratio = None osd_db_size = None @@ -789,15 +788,16 @@ class CephOSDInstance(object): raise Exception # 2. Wait for the OSD to be safe to remove (but don't wait for rebalancing to complete) - logger.out(f"Waiting for OSD {osd_id} to be safe to remove", state="i") - while True: - retcode, stdout, stderr = common.run_os_command( - f"ceph osd safe-to-destroy osd.{osd_id}" - ) - if int(retcode) in [0, 11]: - break - else: - time.sleep(5) + if not force_flag: + logger.out(f"Waiting for OSD {osd_id} to be safe to remove", state="i") + while True: + retcode, stdout, stderr = common.run_os_command( + f"ceph osd safe-to-destroy osd.{osd_id}" + ) + if int(retcode) in [0, 11]: + break + else: + time.sleep(1) # 3. Stop the OSD process and wait for it to be terminated logger.out("Stopping OSD {}".format(osd_id), state="i") @@ -812,7 +812,7 @@ class CephOSDInstance(object): logger.out("Ignoring error due to force flag", state="i") else: raise Exception - time.sleep(2) + time.sleep(5) if not skip_zap_flag: # 4. Determine the block devices @@ -843,7 +843,7 @@ class CephOSDInstance(object): raise Exception # 5. Purge the OSD from Ceph - logger.out("Purging OSD {osd_id}", state="i") + logger.out(f"Purging OSD {osd_id}", state="i") if force_flag: force_arg = "--force" else: