Do not fail cell's instance deletion, if it's missing info_cache
Currently the methods in cell messaging are trying to refresh the
instance. However, in some corner cases info_cache is not being
created for instances in ERROR state. This makes the delete
operation, of such instances, to fail, while it should not.
Handling the InstanceInfoCacheNotFound exception and not
re-raising it, for delete operations.
(cherry picked from commit 47898ba8f9
)
Conflicts:
nova/tests/cells/test_cells_messaging.py
Closes-Bug: #1316373
Change-Id: I33c33e3ac1180e8293d950d60fb126e325a2c0cf
This commit is contained in:
parent
895f22fd8f
commit
82cc3be42f
@ -846,6 +846,10 @@ class _TargetedMessageMethods(_BaseMessageMethods):
|
||||
instance = {'uuid': instance.uuid}
|
||||
self.msg_runner.instance_destroy_at_top(ctxt,
|
||||
instance)
|
||||
except exception.InstanceInfoCacheNotFound:
|
||||
if method != 'delete':
|
||||
raise
|
||||
|
||||
fn = getattr(self.compute_api, method, None)
|
||||
return fn(ctxt, instance, *args, **kwargs)
|
||||
|
||||
|
@ -17,6 +17,9 @@
|
||||
Tests For Cells Messaging module
|
||||
"""
|
||||
|
||||
import contextlib
|
||||
|
||||
import mock
|
||||
import mox
|
||||
from oslo.config import cfg
|
||||
from oslo import messaging as oslo_messaging
|
||||
@ -1131,6 +1134,31 @@ class CellsTargetedMethodsTestCase(test.TestCase):
|
||||
extra_properties='props')
|
||||
self.assertEqual('foo', result)
|
||||
|
||||
def test_call_compute_api_with_obj_no_cache(self):
|
||||
instance = instance_obj.Instance()
|
||||
instance.uuid = uuidutils.generate_uuid()
|
||||
error = exception.InstanceInfoCacheNotFound(
|
||||
instance_uuid=instance.uuid)
|
||||
with mock.patch.object(instance, 'refresh', side_effect=error):
|
||||
self.assertRaises(exception.InstanceInfoCacheNotFound,
|
||||
self.tgt_methods_cls._call_compute_api_with_obj,
|
||||
self.ctxt, instance, 'snapshot')
|
||||
|
||||
def test_call_delete_compute_api_with_obj_no_cache(self):
|
||||
instance = instance_obj.Instance()
|
||||
instance.uuid = uuidutils.generate_uuid()
|
||||
error = exception.InstanceInfoCacheNotFound(
|
||||
instance_uuid=instance.uuid)
|
||||
with contextlib.nested(
|
||||
mock.patch.object(instance, 'refresh',
|
||||
side_effect=error),
|
||||
mock.patch.object(self.tgt_compute_api, 'delete')) as (inst,
|
||||
delete):
|
||||
self.tgt_methods_cls._call_compute_api_with_obj(self.ctxt,
|
||||
instance,
|
||||
'delete')
|
||||
delete.assert_called_once_with(self.ctxt, instance)
|
||||
|
||||
def test_call_compute_with_obj_unknown_instance(self):
|
||||
instance = instance_obj.Instance()
|
||||
instance.uuid = uuidutils.generate_uuid()
|
||||
|
Loading…
Reference in New Issue
Block a user