From ca51db7e2db72cb774c94fb039509f2b4e6c94ca Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Tue, 21 Feb 2017 11:09:16 -0800 Subject: [PATCH] Make conductor create InstanceAction in the proper cell Conductor was not creating the InstanceAction in the appropriate cell (i.e. the same cell as the instance). This fixes that by just moving it into our existing cell-targeted context. Change-Id: I5c1713195585ac9cf34a8f9fc6b5a61afe996034 --- nova/conductor/manager.py | 7 +++---- nova/tests/unit/conductor/test_conductor.py | 13 +++++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/nova/conductor/manager.py b/nova/conductor/manager.py index 3b1ba23d05..9ce2ee1350 100644 --- a/nova/conductor/manager.py +++ b/nova/conductor/manager.py @@ -918,11 +918,10 @@ class ComputeTaskManager(base.Base): notifications.send_update_with_states(context, instance, None, vm_states.BUILDING, None, None, service="conductor") - objects.InstanceAction.action_start( - context, instance.uuid, instance_actions.CREATE, - want_result=False) - with obj_target_cell(instance, cell): + objects.InstanceAction.action_start( + context, instance.uuid, instance_actions.CREATE, + want_result=False) instance_bdms = self._create_block_device_mapping( instance.flavor, instance.uuid, block_device_mapping) diff --git a/nova/tests/unit/conductor/test_conductor.py b/nova/tests/unit/conductor/test_conductor.py index 1a4e325816..1384ae8dbf 100644 --- a/nova/tests/unit/conductor/test_conductor.py +++ b/nova/tests/unit/conductor/test_conductor.py @@ -1459,6 +1459,19 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase): self.assertEqual(1, ephemeral[0].volume_size) + cells = objects.CellMappingList.get_all(self.context) + + # NOTE(danms): Assert that we created the InstanceAction in the + # correct cell + for cell in cells: + with context.target_cell(self.context, cell): + actions = objects.InstanceActionList.get_by_instance_uuid( + self.context, instance_uuid) + if cell.name == 'cell1': + self.assertEqual(1, len(actions)) + else: + self.assertEqual(0, len(actions)) + @mock.patch('nova.compute.rpcapi.ComputeAPI.build_and_run_instance') @mock.patch('nova.scheduler.rpcapi.SchedulerAPI.select_destinations') @mock.patch('nova.objects.HostMapping.get_by_host')