Fix cells instance deletion
Instance delete and soft_delete are broken with cells when the API doesn't know the cell of an instance. A traceback occurs in all child cells. Also: soft_delete results in a 'hard' type being sent to child cells vs 'soft'. Fixes bug 1154333 Change-Id: I13ac839fa13a66caa100a3459bcc8e1183821ff1
This commit is contained in:
@@ -255,9 +255,9 @@ class ComputeCellsAPI(compute_api.API):
|
||||
# broadcast a message down to all cells and hope this ends
|
||||
# up resolving itself... Worse case.. the instance will
|
||||
# show back up again here.
|
||||
delete_type = method == 'soft_delete' and 'soft' or 'hard'
|
||||
delete_type = method_name == 'soft_delete' and 'soft' or 'hard'
|
||||
self.cells_rpcapi.instance_delete_everywhere(context,
|
||||
instance['uuid'], delete_type)
|
||||
instance, delete_type)
|
||||
|
||||
@validate_cell
|
||||
def restore(self, context, instance):
|
||||
|
||||
@@ -20,6 +20,7 @@ import functools
|
||||
|
||||
from nova.compute import cells_api as compute_cells_api
|
||||
from nova import db
|
||||
from nova import exception
|
||||
from nova.openstack.common import jsonutils
|
||||
from nova.openstack.common import log as logging
|
||||
from nova.tests.compute import test_compute
|
||||
@@ -171,6 +172,36 @@ class CellsComputeAPITestCase(test_compute.ComputeAPITestCase):
|
||||
def test_evacuate(self):
|
||||
self.skipTest("Test is incompatible with cells.")
|
||||
|
||||
def test_delete_instance_no_cell(self):
|
||||
cells_rpcapi = self.compute_api.cells_rpcapi
|
||||
self.mox.StubOutWithMock(cells_rpcapi,
|
||||
'instance_delete_everywhere')
|
||||
self.mox.StubOutWithMock(self.compute_api,
|
||||
'_cast_to_cells')
|
||||
inst = self._create_fake_instance()
|
||||
exc = exception.InstanceUnknownCell(instance_uuid=inst['uuid'])
|
||||
self.compute_api._cast_to_cells(self.context, inst,
|
||||
'delete').AndRaise(exc)
|
||||
cells_rpcapi.instance_delete_everywhere(self.context,
|
||||
inst, 'hard')
|
||||
self.mox.ReplayAll()
|
||||
self.compute_api.delete(self.context, inst)
|
||||
|
||||
def test_soft_delete_instance_no_cell(self):
|
||||
cells_rpcapi = self.compute_api.cells_rpcapi
|
||||
self.mox.StubOutWithMock(cells_rpcapi,
|
||||
'instance_delete_everywhere')
|
||||
self.mox.StubOutWithMock(self.compute_api,
|
||||
'_cast_to_cells')
|
||||
inst = self._create_fake_instance()
|
||||
exc = exception.InstanceUnknownCell(instance_uuid=inst['uuid'])
|
||||
self.compute_api._cast_to_cells(self.context, inst,
|
||||
'soft_delete').AndRaise(exc)
|
||||
cells_rpcapi.instance_delete_everywhere(self.context,
|
||||
inst, 'soft')
|
||||
self.mox.ReplayAll()
|
||||
self.compute_api.soft_delete(self.context, inst)
|
||||
|
||||
|
||||
class CellsComputePolicyTestCase(test_compute.ComputePolicyTestCase):
|
||||
def setUp(self):
|
||||
|
||||
Reference in New Issue
Block a user