Fix evacuate support with Nova cells v1

Cells v1 does not properly support evacuate when destination node is provided.
If a destination node is provided, evacuated instance will stay
in 'REBUILDING' state forever.

The evacuate method expects host to be the actual node name,
not one with complete cell_path. Stripping the cell_path from the host
fixes the problem.

Closes-bug: #1552046
Change-Id: Ib48990100ecc02325d323c8e933a859fa839a1a2
This commit is contained in:
Mathieu Gagné 2015-09-24 13:43:27 -04:00
parent 2fc930a84e
commit 022802997c
2 changed files with 15 additions and 5 deletions
nova
compute
tests/unit/compute

@ -261,11 +261,12 @@ class ComputeCellsAPI(compute_api.API):
self._cast_to_cells(context, instance, 'restore')
@check_instance_cell
def evacuate(self, context, instance, *args, **kwargs):
def evacuate(self, context, instance, host, *args, **kwargs):
"""Evacuate the given instance with the provided attributes."""
super(ComputeCellsAPI, self).evacuate(context, instance, *args,
**kwargs)
self._cast_to_cells(context, instance, 'evacuate', *args, **kwargs)
if host:
cell_path, host = cells_utils.split_cell_and_item(host)
self._cast_to_cells(context, instance, 'evacuate',
host, *args, **kwargs)
@check_instance_cell
def add_fixed_ip(self, context, instance, *args, **kwargs):

@ -131,7 +131,16 @@ class CellsComputeAPITestCase(test_compute.ComputeAPITestCase):
self.skipTest("Test is incompatible with cells.")
def test_evacuate(self):
self.skipTest("Test is incompatible with cells.")
@mock.patch.object(compute_api.API, 'evacuate')
def _test(mock_evacuate):
instance = objects.Instance(uuid=uuids.evacuate_instance,
cell_name='fake_cell_name')
dest_host = 'fake_cell_name@fakenode2'
self.compute_api.evacuate(self.context, instance, host=dest_host)
mock_evacuate.assert_called_once_with(
self.context, instance, 'fakenode2')
_test()
def test_error_evacuate(self):
self.skipTest("Test is incompatible with cells.")