Skip to content
This repository has been archived by the owner on Apr 18, 2019. It is now read-only.

Commit

Permalink
Merge pull request #559 from flyingfish007/master
Browse files Browse the repository at this point in the history
fix an issue that fail to add the removed server with more than one osd
  • Loading branch information
ywang19 authored Jul 28, 2016
2 parents 554cb61 + 121a72c commit daebe92
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
10 changes: 5 additions & 5 deletions source/vsm/vsm/agent/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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)
Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion source/vsm/vsm/agent/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion source/vsm/vsm/db/sqlalchemy/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
20 changes: 14 additions & 6 deletions source/vsm/vsm/scheduler/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit daebe92

Please sign in to comment.