From d1711aab80a2af477f56afcc435468409fd3ad89 Mon Sep 17 00:00:00 2001 From: Clark Boylan Date: Tue, 1 Apr 2014 20:40:26 -0700 Subject: [PATCH] Immediately delete a floating IP if doesn't attach When floating IPs fail to attach to nodes nodepool leaks that floating IP. Correct this by immediately removing the floating IP as we have the IPs id after creation but not during cleanupServer (because the floating IP was never associated to any server). Closes-Bug: #1301111 Change-Id: Ib6460797a8d9b31b1ad723e056dbfe6d57438bf7 --- nodepool/provider_manager.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/nodepool/provider_manager.py b/nodepool/provider_manager.py index fbda4bab0..a2adb2284 100644 --- a/nodepool/provider_manager.py +++ b/nodepool/provider_manager.py @@ -389,7 +389,14 @@ class ProviderManager(TaskManager): def addPublicIP(self, server_id, pool=None): ip = self.createFloatingIP(pool) - self.addFloatingIP(server_id, ip['ip']) + try: + self.addFloatingIP(server_id, ip['ip']) + except novaclient.exceptions.ClientException: + # Delete the floating IP here as cleanupServer will not + # have access to the ip -> server mapping preventing it + # from removing this IP. + self.deleteFloatingIP(ip['id']) + raise for count in iterate_timeout(600, "ip to be added to %s in %s" % (server_id, self.provider.name)): try: