Add exception handling in _cleanup_allocated_network

The _cleanup_allocated_network method used in nova.compute.manager.py
has exception handling around deallocate_for_instance.  That should
be added in nova.condutor.manager as well. Without it we'll end up
with the RPC layer complaining about unexpected exceptions.

This commit add exception handling logic around deallocate_for_instance
nova.conductor.manager._cleanup_allocated_network() method.

Change-Id: Id536e2b4794d56a32af4d13577415e427e2eeb2d
This commit is contained in:
Wen Zhi Yu 2016-01-19 15:28:02 +08:00
parent 49c05a2430
commit a70af8319c

View File

@ -254,8 +254,22 @@ class ComputeTaskManager(base.Base):
def _cleanup_allocated_networks(
self, context, instance, requested_networks):
self.network_api.deallocate_for_instance(
context, instance, requested_networks=requested_networks)
try:
self.network_api.deallocate_for_instance(
context, instance, requested_networks=requested_networks)
except Exception:
msg = _LE('Failed to deallocate networks')
LOG.exception(msg, instance=instance)
return
instance.system_metadata['network_allocated'] = 'False'
try:
instance.save()
except exception.InstanceNotFound:
# NOTE: It's possible that we're cleaning up the networks
# because the instance was deleted. If that's the case then this
# exception will be raised by instance.save()
pass
def _live_migrate(self, context, instance, scheduler_hint,
block_migration, disk_over_commit):