Merge "Cleanup leaked floating ips periodically"

This commit is contained in:
Jenkins 2016-05-12 15:25:25 +00:00 committed by Gerrit Code Review
commit 6b2636a0b5
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