[ADMIN_API][MGM]: Be nicer to Nova networks for deletes
Instead of deleting a bad instance instantly add to the DB with a DELETED status so that the next run of the delete scheduler will wipe it out. Change-Id: Ib5518ef51176729baa703eeb410911cd8437fa9c
This commit is contained in:
@@ -314,6 +314,8 @@ class GearmanWork(object):
|
||||
continue
|
||||
if status.result['response'] == 'FAIL':
|
||||
LOG.error('Pool manager failed to build a device')
|
||||
if 'name' in status.result:
|
||||
self._add_bad_node(status.result)
|
||||
continue
|
||||
|
||||
built_count += 1
|
||||
@@ -351,3 +353,21 @@ class GearmanWork(object):
|
||||
with db_session() as session:
|
||||
session.add(device)
|
||||
session.commit()
|
||||
|
||||
def _add_bad_node(self, data):
|
||||
LOG.info(
|
||||
'Adding bad device {0} to DB to be deleted'.format(data['name'])
|
||||
)
|
||||
device = Device()
|
||||
device.name = data['name']
|
||||
device.publicIpAddr = data['addr']
|
||||
# TODO: kill this field, make things use publicIpAddr instead
|
||||
device.floatingIpAddr = data['addr']
|
||||
device.az = data['az']
|
||||
device.type = data['type']
|
||||
device.pingCount = 0
|
||||
device.status = 'DELETED'
|
||||
device.created = None
|
||||
with db_session() as session:
|
||||
session.add(device)
|
||||
session.commit()
|
||||
|
||||
@@ -121,9 +121,8 @@ class BuildController(object):
|
||||
return self.msg
|
||||
sleep(60)
|
||||
|
||||
nova.delete(node_id)
|
||||
LOG.error(
|
||||
"Node {0} didn't come up after 10 minutes, deleted".format(node_id)
|
||||
"Node {0} didn't come up after 10 minutes".format(node_id)
|
||||
)
|
||||
self.msg[self.RESPONSE_FIELD] = self.RESPONSE_FAILURE
|
||||
return self.msg
|
||||
|
||||
Reference in New Issue
Block a user