Merge "Compute: catch more specific exception for _get_instance_nw_info"
This commit is contained in:
@@ -5337,6 +5337,11 @@ class ComputeManager(manager.Manager):
|
||||
self._get_instance_nw_info(context, instance, use_slave=True)
|
||||
LOG.debug('Updated the network info_cache for instance',
|
||||
instance=instance)
|
||||
except exception.InstanceNotFound:
|
||||
# Instance is gone.
|
||||
LOG.debug('Instance no longer exists. Unable to refresh',
|
||||
instance=instance)
|
||||
return
|
||||
except Exception:
|
||||
LOG.error(_LE('An error occurred while refreshing the network '
|
||||
'cache.'), instance=instance, exc_info=True)
|
||||
|
||||
@@ -6099,7 +6099,7 @@ class ComputeTestCase(BaseTestCase):
|
||||
fake_inst_obj)
|
||||
self.assertEqual(fake_nw_info, result)
|
||||
|
||||
def test_heal_instance_info_cache(self):
|
||||
def _heal_instance_info_cache(self, _get_instance_nw_info_raise=False):
|
||||
# Update on every call for the test
|
||||
self.flags(heal_instance_info_cache_interval=-1)
|
||||
ctxt = context.get_admin_context()
|
||||
@@ -6140,6 +6140,8 @@ class ComputeTestCase(BaseTestCase):
|
||||
self.assertEqual(call_info['expected_instance']['uuid'],
|
||||
instance['uuid'])
|
||||
call_info['get_nw_info'] += 1
|
||||
if _get_instance_nw_info_raise:
|
||||
raise exception.InstanceNotFound(instance_id=instance['uuid'])
|
||||
|
||||
self.stubs.Set(db, 'instance_get_all_by_host',
|
||||
fake_instance_get_all_by_host)
|
||||
@@ -6193,6 +6195,12 @@ class ComputeTestCase(BaseTestCase):
|
||||
# Stays the same because we didn't find anything to process
|
||||
self.assertEqual(3, call_info['get_nw_info'])
|
||||
|
||||
def test_heal_instance_info_cache(self):
|
||||
self._heal_instance_info_cache()
|
||||
|
||||
def test_heal_instance_info_cache_with_exception(self):
|
||||
self._heal_instance_info_cache(_get_instance_nw_info_raise=True)
|
||||
|
||||
@mock.patch('nova.objects.InstanceList.get_by_filters')
|
||||
@mock.patch('nova.compute.api.API.unrescue')
|
||||
def test_poll_rescued_instances(self, unrescue, get):
|
||||
|
||||
Reference in New Issue
Block a user