Cleanup leaked floating ips periodically

It should not happen in a neutron setup that we have leaked floating
ips. However, sometimes it seems that it happens around startup. It's
also safe in a neutron context to just clean the unattached ones. So
assume that sometimes clouds get into weird states and just clean them.

Change-Id: I1a30efb3b7994381592c2391881711d6b1f32dff
Depends-On: I93b0c7d0b0eefdfe0fb1cd4a66cdbba9baabeb09
This commit is contained in:
Monty Taylor 2016-04-19 07:22:58 -05:00
parent e0f65825b0
commit 60e49f110b
No known key found for this signature in database
GPG Key ID: 3390DB68041A12F0
5 changed files with 14 additions and 1 deletions

View File

@ -440,6 +440,11 @@ provider, the Nodepool image types are also defined (see
``rate``
In seconds. Default 1.0.
``clean-floating-ips``
If it is set to True, nodepool will assume it is the only user of the
OpenStack project and will attempt to clean unattached floating ips that
may have leaked around restarts.
.. _images:
images

View File

@ -47,6 +47,7 @@ class Provider(ConfigValue):
other.launch_timeout != self.launch_timeout or
other.networks != self.networks or
other.ipv6_preferred != self.ipv6_preferred or
other.clean_floating_ips != self.clean_floating_ips or
other.azs != self.azs):
return False
new_images = other.images
@ -184,6 +185,7 @@ def loadConfig(config_path):
n.id = None
n.public = network.get('public', False)
p.ipv6_preferred = provider.get('ipv6-preferred')
p.clean_floating_ips = provider.get('clean_floating_ips')
p.azs = provider.get('availability-zones')
p.template_hostname = provider.get(
'template-hostname',

View File

@ -2083,6 +2083,8 @@ class NodePool(threading.Thread):
server['name'], server['id'],
provider.name))
continue
if provider.clean_floating_ips:
manager.cleanupLeakedFloaters()
def cleanupOneNode(self, session, node):
now = time.time()

View File

@ -342,6 +342,10 @@ class ProviderManager(TaskManager):
self.log.debug('Deleting server %s' % server_id)
self.deleteServer(server_id)
def cleanupLeakedFloaters(self):
with shade_inner_exceptions():
self._client.delete_unattached_floating_ips()
class FakeProviderManager(ProviderManager):
def __init__(self, provider):

View File

@ -15,6 +15,6 @@ PrettyTable>=0.6,<0.8
# shade has a looser requirement on six than nodepool, so install six first
six>=1.7.0
os-client-config>=1.2.0
shade>=1.6.2
shade>=1.8.0
diskimage-builder
voluptuous