Ignore Cinder error when shutdown instance

Ignore cinder errors when doing shutdown, thus we will continue
the cleanup even if some exceptions there, so we won't get
a couple of instance which can't be deleted

Change-Id: I3c7202524857e2205b2442bbbcce9468cb2172c3
Closes-Bug: 1450658
This commit is contained in:
jichenjc 2015-05-06 19:57:29 +08:00
parent 30564b9207
commit e6d700b0d2
2 changed files with 13 additions and 2 deletions

View File

@ -2278,6 +2278,9 @@ class ComputeManager(manager.Manager):
keystone_exception.EndpointNotFound) as exc:
LOG.warning(_LW('Ignoring EndpointNotFound: %s'), exc,
instance=instance)
except cinder_exception.ClientException as exc:
LOG.warning(_LW('Ignoring Unknown cinder exception: %s'), exc,
instance=instance)
if notify:
self._notify_about_instance_usage(context, instance,

View File

@ -927,9 +927,9 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase):
'nova.compute.manager.ComputeManager._get_instance_block_device_info')
@mock.patch('nova.virt.driver.ComputeDriver.destroy')
@mock.patch('nova.virt.driver.ComputeDriver.get_volume_connector')
def test_shutdown_instance_endpoint_not_found(self, mock_connector,
def _test_shutdown_instance_exception(self, exc, mock_connector,
mock_destroy, mock_blk_device_info, mock_nw_info, mock_elevated):
mock_connector.side_effect = cinder_exception.EndpointNotFound
mock_connector.side_effect = exc
mock_elevated.return_value = self.context
instance = fake_instance.fake_instance_obj(
self.context,
@ -941,6 +941,14 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase):
self.compute._shutdown_instance(self.context, instance, bdms,
notify=False, try_deallocate_networks=False)
def test_shutdown_instance_endpoint_not_found(self):
exc = cinder_exception.EndpointNotFound
self._test_shutdown_instance_exception(exc)
def test_shutdown_instance_client_exception(self):
exc = cinder_exception.ClientException
self._test_shutdown_instance_exception(exc)
def _test_init_instance_retries_reboot(self, instance, reboot_type,
return_power_state):
instance.host = self.compute.host