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
This commit is contained in:
Clark Boylan 2014-04-01 20:40:26 -07:00
parent 418d1cee95
commit d1711aab80

View File

@ -389,7 +389,14 @@ class ProviderManager(TaskManager):
def addPublicIP(self, server_id, pool=None): def addPublicIP(self, server_id, pool=None):
ip = self.createFloatingIP(pool) ip = self.createFloatingIP(pool)
try:
self.addFloatingIP(server_id, ip['ip']) 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" % for count in iterate_timeout(600, "ip to be added to %s in %s" %
(server_id, self.provider.name)): (server_id, self.provider.name)):
try: try: