diff options
| author | Jenkins <jenkins@review.openstack.org> | 2013-06-08 01:17:18 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2013-06-08 01:17:18 +0000 |
| commit | e0142d0f63bf64a07db3bd3b840fc2072d2e6ca3 (patch) | |
| tree | 375cdadf8c1b20229b94352887213a292bcdf983 /nova/compute | |
| parent | 08d6c1dd3d8819a73c35c2c59ac5e50224fb9a73 (diff) | |
| parent | dacb187fcd685c15fd084fdfce8c5e165130ff54 (diff) | |
| download | nova-e0142d0f63bf64a07db3bd3b840fc2072d2e6ca3.tar.gz nova-e0142d0f63bf64a07db3bd3b840fc2072d2e6ca3.tar.xz nova-e0142d0f63bf64a07db3bd3b840fc2072d2e6ca3.zip | |
Merge "Call virt.driver.destroy before deallocating network."
Diffstat (limited to 'nova/compute')
| -rwxr-xr-x | nova/compute/manager.py | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 2390eb3c3..998be6f76 100755 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -1297,6 +1297,16 @@ class ComputeManager(manager.SchedulerDependentManager): admin_password, is_first_time, node, instance) do_run_instance() + def _try_deallocate_network(self, context, instance): + try: + # tear down allocated network structure + self._deallocate_network(context, instance) + except Exception: + with excutils.save_and_reraise_exception(): + LOG.error(_('Failed to deallocate network for instance.'), + instance=instance) + self._set_instance_error_state(context, instance['uuid']) + def _shutdown_instance(self, context, instance, bdms): """Shutdown an instance on this host.""" context = context.elevated() @@ -1311,21 +1321,28 @@ class ComputeManager(manager.SchedulerDependentManager): except exception.NetworkNotFound: network_info = network_model.NetworkInfo() - try: - # tear down allocated network structure - self._deallocate_network(context, instance) - except Exception: - with excutils.save_and_reraise_exception(): - LOG.error(_('Failed to deallocate network for instance.'), - instance=instance) - self._set_instance_error_state(context, instance['uuid']) - # NOTE(vish) get bdms before destroying the instance vol_bdms = self._get_volume_bdms(bdms) block_device_info = self._get_instance_volume_block_device_info( context, instance, bdms=bdms) - self.driver.destroy(instance, self._legacy_nw_info(network_info), - block_device_info) + + # NOTE(melwitt): attempt driver destroy before releasing ip, may + # want to keep ip allocated for certain failures + try: + self.driver.destroy(instance, self._legacy_nw_info(network_info), + block_device_info) + except exception.InstancePowerOffFailure: + # if the instance can't power off, don't release the ip + with excutils.save_and_reraise_exception(): + pass + except Exception: + with excutils.save_and_reraise_exception(): + # deallocate ip and fail without proceeding to + # volume api calls, preserving current behavior + self._try_deallocate_network(context, instance) + + self._try_deallocate_network(context, instance) + for bdm in vol_bdms: try: # NOTE(vish): actual driver detach done in driver.destroy, so |
