Process unlimited exceptions raised by unplug_vifs
Currently compute manager's _cleanup_allocated_networks() method expects NotImplementedError or exception.NovaException when calling self.driver.unplug_vifs. In reality, other class of exception could be raised. It could break the Nova Compute flow and leave instance in inconsistent state. This patch switches from exception.NovaException to all kinds of exceptions. Closes-bug: #2015092 Change-Id: Icaf3cc93edfea97ee4fa497bdeb5f7d631c8ae55
This commit is contained in:
parent
29de62bf3b
commit
dacae335e4
@ -2985,7 +2985,7 @@ class ComputeManager(manager.Manager):
|
|||||||
'Virt driver does not provide unplug_vifs method, so it '
|
'Virt driver does not provide unplug_vifs method, so it '
|
||||||
'is not possible determine if VIFs should be unplugged.'
|
'is not possible determine if VIFs should be unplugged.'
|
||||||
)
|
)
|
||||||
except exception.NovaException as exc:
|
except Exception as exc:
|
||||||
# It's possible that the instance never got as far as plugging
|
# It's possible that the instance never got as far as plugging
|
||||||
# VIFs, in which case we would see an exception which can be
|
# VIFs, in which case we would see an exception which can be
|
||||||
# mostly ignored
|
# mostly ignored
|
||||||
|
@ -8478,7 +8478,7 @@ class ComputeManagerBuildInstanceTestCase(test.NoDBTestCase):
|
|||||||
'False', self.instance.system_metadata['network_allocated'])
|
'False', self.instance.system_metadata['network_allocated'])
|
||||||
|
|
||||||
@mock.patch('nova.compute.manager.LOG')
|
@mock.patch('nova.compute.manager.LOG')
|
||||||
def test__cleanup_allocated_networks__error(self, mock_log):
|
def test__cleanup_allocated_networks_neutron_error(self, mock_log):
|
||||||
with test.nested(
|
with test.nested(
|
||||||
mock.patch.object(
|
mock.patch.object(
|
||||||
self.compute.network_api, 'get_instance_nw_info',
|
self.compute.network_api, 'get_instance_nw_info',
|
||||||
@ -8497,6 +8497,29 @@ class ComputeManagerBuildInstanceTestCase(test.NoDBTestCase):
|
|||||||
)
|
)
|
||||||
mock_unplug.assert_not_called()
|
mock_unplug.assert_not_called()
|
||||||
|
|
||||||
|
@mock.patch('nova.compute.manager.LOG.warning')
|
||||||
|
def test__cleanup_allocated_networks_osvif_error(self, mock_log):
|
||||||
|
with test.nested(
|
||||||
|
mock.patch.object(self.compute.network_api,
|
||||||
|
'get_instance_nw_info'),
|
||||||
|
mock.patch.object(self.compute.driver, 'unplug_vifs',
|
||||||
|
side_effect=ValueError('Malformed MAC 40:28:0:00:2:6')),
|
||||||
|
mock.patch.object(self.compute, '_deallocate_network'),
|
||||||
|
mock.patch.object(self.instance, 'save'),
|
||||||
|
) as (mock_nwinfo, mock_unplug, mock_deallocate_network, mock_save):
|
||||||
|
self.compute._cleanup_allocated_networks(
|
||||||
|
self.context, self.instance, self.requested_networks)
|
||||||
|
|
||||||
|
mock_nwinfo.assert_called_once_with(self.context, self.instance)
|
||||||
|
self.assertEqual(1, mock_log.call_count)
|
||||||
|
self.assertIn(
|
||||||
|
'Cleaning up VIFs failed for instance. Error: %s',
|
||||||
|
mock_log.call_args[0][0],
|
||||||
|
)
|
||||||
|
mock_deallocate_network.assert_called_once_with(
|
||||||
|
self.context, self.instance, self.requested_networks)
|
||||||
|
mock_save.assert_called_once_with()
|
||||||
|
|
||||||
def test_split_network_arqs(self):
|
def test_split_network_arqs(self):
|
||||||
arqs = [
|
arqs = [
|
||||||
{'uuid': uuids.arq_uuid1},
|
{'uuid': uuids.arq_uuid1},
|
||||||
|
Loading…
Reference in New Issue
Block a user