Fixed issue where the floating ip does not get cleaned up when there is an error from the unicorn api

This commit is contained in:
Alan Quillin
2016-03-14 14:01:15 -04:00
parent b52da4a639
commit 91628ec5a0

View File

@@ -271,13 +271,20 @@ def delete_floatingip(context, id):
if flip.fixed_ip:
flip = db_api.floating_ip_disassociate_fixed_ip(context, flip)
driver = registry.DRIVER_REGISTRY.get_driver()
driver.remove_floating_ip(flip)
context.session.commit()
except Exception:
context.session.rollback()
raise
try:
driver = registry.DRIVER_REGISTRY.get_driver()
driver.remove_floating_ip(flip)
except Exception as e:
LOG.error('There was an error when trying to delete the floating ip '
'on the unicorn API. The ip has been cleaned up, but '
'may need to be handled manually in the unicorn API. '
'Error: %s' % e.message)
def get_floatingip(context, id, fields=None):
"""Retrieve a floating IP.