From 040ca336832c2cf36872d499fba7c42dcff9cca7 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Tue, 22 Oct 2019 12:51:29 -0400 Subject: [PATCH] Clean up handling of OSD dump command --- node-daemon/pvcd/CephInstance.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/node-daemon/pvcd/CephInstance.py b/node-daemon/pvcd/CephInstance.py index 8d7e5f44..c7580037 100644 --- a/node-daemon/pvcd/CephInstance.py +++ b/node-daemon/pvcd/CephInstance.py @@ -213,16 +213,19 @@ def remove_osd(zk_conn, logger, osd_id, osd_obj): logger.out('Flushing OSD disk with ID {}'.format(osd_id), state='i') osd_string = str() while True: - retcode, stdout, stderr = common.run_os_command('ceph pg dump osds --format json') - dump_string = json.loads(stdout) - for osd in dump_string: - if str(osd['osd']) == osd_id: - osd_string = osd - num_pgs = osd_string['num_pgs'] - if num_pgs > 0: - time.sleep(5) - else: - break + try: + retcode, stdout, stderr = common.run_os_command('ceph pg dump osds --format json') + dump_string = json.loads(stdout) + for osd in dump_string: + if str(osd['osd']) == osd_id: + osd_string = osd + num_pgs = osd_string['num_pgs'] + if num_pgs > 0: + time.sleep(5) + else: + raise + except: + break # 3. Stop the OSD process and wait for it to be terminated logger.out('Stopping OSD disk with ID {}'.format(osd_id), state='i')