From 92a03aaead36ad6f27efd98b26d9bbfe62fd025a Mon Sep 17 00:00:00 2001 From: flyingfish007 Date: Wed, 27 Jul 2016 11:09:19 +0800 Subject: [PATCH 1/2] fix an issue that fail to add the removed server with more than one osd --- source/vsm/vsm/agent/driver.py | 2 +- source/vsm/vsm/db/sqlalchemy/api.py | 2 +- source/vsm/vsm/scheduler/manager.py | 20 ++++++++++++++------ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/source/vsm/vsm/agent/driver.py b/source/vsm/vsm/agent/driver.py index 2c3d16c8e..c0feaa352 100644 --- a/source/vsm/vsm/agent/driver.py +++ b/source/vsm/vsm/agent/driver.py @@ -1750,7 +1750,7 @@ def __is_host_running(host): # step 5 LOG.info('>>> remove ceph osd step5 osd_id %s' % osd_id) osd_name = 'osd.%s' % osd_id - val = { 'osd_name': osd_name, 'deleted': 1 } + val = { 'osd_name': osd_name, 'deleted': 0 } self._conductor_rpcapi.osd_state_update(context, val) LOG.info('>>> remove ceph osd step 1-5 osd_id %s' % osd_id) diff --git a/source/vsm/vsm/db/sqlalchemy/api.py b/source/vsm/vsm/db/sqlalchemy/api.py index 7dc587447..3c2cd620a 100644 --- a/source/vsm/vsm/db/sqlalchemy/api.py +++ b/source/vsm/vsm/db/sqlalchemy/api.py @@ -3158,7 +3158,7 @@ def update_deleted_osd_state_by_service_id(context, service_id, values): session = get_session() with session.begin(): result = model_query( - context, models.OsdState, read_deleted="only",session=session,).\ + context, models.OsdState, read_deleted="yes",session=session,).\ filter_by(service_id=service_id).\ all() #LOG.info('update_deleted_osd_state_by_service_id--%s-'%result) diff --git a/source/vsm/vsm/scheduler/manager.py b/source/vsm/vsm/scheduler/manager.py index 3bd87cf2e..c7caadc87 100644 --- a/source/vsm/vsm/scheduler/manager.py +++ b/source/vsm/vsm/scheduler/manager.py @@ -809,17 +809,25 @@ def remove_servers(self, context, body=None): LOG.info("start to remove storage") self.remove_osd(context, server_list) - values = {'osd_name': "osd.%s"%FLAGS.vsm_status_uninitialized, - 'osd_location':'', - 'deleted':0, - 'state':FLAGS.vsm_status_uninitialized,} + values = { + "osd_name": "osd.%s" % str(FLAGS.vsm_status_uninitialized), + "osd_location": "", + "deleted": False, + "operation_status": "Present", + "state": str(FLAGS.vsm_status_uninitialized) + } LOG.info("update deleted osd to uninited") for server in server_list: service_id = server['service_id'] - db.update_deleted_osd_state_by_service_id(context,service_id,values) + osd_states = db.osd_state_get_by_service_id(context, service_id) + while True: + if osd_states[0].state == "Out-Down": + break + osd_states = db.osd_state_get_by_service_id(context, service_id) + time.sleep(5) + db.update_deleted_osd_state_by_service_id(context, service_id, values) LOG.info("update deleted osd to uninited over") - if need_change_mds: LOG.info("start to remove mds") self.remove_mds(context, server_list) From 121a72c9a38210df4bfb6382d2abd5ddae5aeeb0 Mon Sep 17 00:00:00 2001 From: flyingfish007 Date: Wed, 27 Jul 2016 13:50:26 +0800 Subject: [PATCH 2/2] fix an issue that fail to add the removed server with more than one osd --- source/vsm/vsm/agent/driver.py | 8 ++++---- source/vsm/vsm/agent/manager.py | 2 +- source/vsm/vsm/scheduler/manager.py | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/source/vsm/vsm/agent/driver.py b/source/vsm/vsm/agent/driver.py index c0feaa352..7c34080ef 100644 --- a/source/vsm/vsm/agent/driver.py +++ b/source/vsm/vsm/agent/driver.py @@ -1452,7 +1452,7 @@ def _add_osd(self, # run_as_root=True) all_osd_in_host = db.osd_state_get_by_service_id(context,osd_state['service_id']) - other_osd_in_host = [osd['osd_name'] for osd in all_osd_in_host if osd['device_id'] != osd_state['device_id'] and osd['state'] != 'Uninitialized'] + # other_osd_in_host = [osd['osd_name'] for osd in all_osd_in_host if osd['device_id'] != osd_state['device_id'] and osd['state'] != 'Uninitialized'] crushmap = self.get_crushmap_json_format() LOG.info("osd_location_direct=======%s"%osd_state.get('osd_location')) osd_location_direct = osd_state.get('osd_location') @@ -1461,9 +1461,9 @@ def _add_osd(self, osd_location_str = osd_location_direct else: osd_location_str = "%s=%s"%(crushmap._types[1]['name'],osd_location_direct) - elif len(other_osd_in_host) > 0: - osd_location = crushmap._get_location_by_osd_name(other_osd_in_host[0]) - osd_location_str = "%s=%s"%(osd_location['type_name'],osd_location['name']) + # elif len(other_osd_in_host) > 0: + # osd_location = crushmap._get_location_by_osd_name(other_osd_in_host[0]) + # osd_location_str = "%s=%s"%(osd_location['type_name'],osd_location['name']) else: osd_location = crush_dict['host'] osd_location_str = "%s=%s"%(crushmap._types[1]['name'],osd_location) diff --git a/source/vsm/vsm/agent/manager.py b/source/vsm/vsm/agent/manager.py index 417878b34..c3f7fd5a4 100644 --- a/source/vsm/vsm/agent/manager.py +++ b/source/vsm/vsm/agent/manager.py @@ -1198,7 +1198,7 @@ def update_osds_status(self, context): value= {} value['id'] = osd_id value['osd_name'] = 'osd.x' - value['state'] = 'Out-Down' + value['state'] = str(FLAGS.vsm_status_uninitialized) value['operation_status'] = FLAGS.vsm_status_removed db.osd_state_update(context, osd_id, value) diff --git a/source/vsm/vsm/scheduler/manager.py b/source/vsm/vsm/scheduler/manager.py index c7caadc87..1fafacd1c 100644 --- a/source/vsm/vsm/scheduler/manager.py +++ b/source/vsm/vsm/scheduler/manager.py @@ -813,7 +813,7 @@ def remove_servers(self, context, body=None): "osd_name": "osd.%s" % str(FLAGS.vsm_status_uninitialized), "osd_location": "", "deleted": False, - "operation_status": "Present", + # "operation_status": "Present", "state": str(FLAGS.vsm_status_uninitialized) } LOG.info("update deleted osd to uninited")