From 9043c48bf5a2a09cf0334abc3857a05b32f6161e Mon Sep 17 00:00:00 2001 From: Andrew Hutchings Date: Thu, 21 Nov 2013 11:22:04 +0000 Subject: [PATCH] [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 --- libra/admin_api/device_pool/manage_pool.py | 20 ++++++++++++++++++++ libra/mgm/controllers/build.py | 3 +-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/libra/admin_api/device_pool/manage_pool.py b/libra/admin_api/device_pool/manage_pool.py index e464d4a7..eac7c88a 100644 --- a/libra/admin_api/device_pool/manage_pool.py +++ b/libra/admin_api/device_pool/manage_pool.py @@ -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() diff --git a/libra/mgm/controllers/build.py b/libra/mgm/controllers/build.py index 0a75427a..7df2c85d 100644 --- a/libra/mgm/controllers/build.py +++ b/libra/mgm/controllers/build.py @@ -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