Remove legacy RequestSpec compat code from live migrate task

Change I34ffaf285718059b55f90e812b57f1e11d566c6f made the
RequestSpec lookup required in the API, so we should not get
to conductor during a live migration without a request spec.
This change removes the old compat code from the conductor
live migration task.

Related to blueprint request-spec-use-by-compute

Change-Id: I88e175ed4e6d509029aef256d69686d1876374bb
This commit is contained in:
Matt Riedemann 2018-12-17 14:02:22 -05:00
parent 52d515ba7d
commit f7f8f89433
2 changed files with 5 additions and 62 deletions

View File

@ -24,7 +24,6 @@ from nova.i18n import _
from nova import network
from nova import objects
from nova.scheduler import utils as scheduler_utils
from nova import utils
LOG = logging.getLogger(__name__)
CONF = nova.conf.CONF
@ -314,20 +313,6 @@ class LiveMigrationTask(base.TaskBase):
This is generally at least seeded with the source host.
:returns: nova.objects.RequestSpec object
"""
if not self.request_spec:
# NOTE(sbauza): We were unable to find an original RequestSpec
# object - probably because the instance is old.
# We need to mock that the old way
image = utils.get_image_from_system_metadata(
self.instance.system_metadata)
filter_properties = {'ignore_hosts': attempted_hosts}
request_spec = objects.RequestSpec.from_components(
self.context, self.instance.uuid, image,
self.instance.flavor, self.instance.numa_topology,
self.instance.pci_requests,
filter_properties, None, self.instance.availability_zone
)
else:
request_spec = self.request_spec
# NOTE(sbauza): Force_hosts/nodes needs to be reset
# if we want to make sure that the next destination

View File

@ -27,7 +27,6 @@ from nova.scheduler import utils as scheduler_utils
from nova import servicegroup
from nova import test
from nova.tests.unit import fake_instance
from nova import utils
fake_selection1 = objects.Selection(service_host="host1", nodename="node1",
@ -358,47 +357,6 @@ class LiveMigrationTaskTestCase(test.NoDBTestCase):
mock_check.assert_called_once_with('host1')
mock_call.assert_called_once_with('host1')
def test_find_destination_works_with_no_request_spec(self):
task = live_migrate.LiveMigrationTask(
self.context, self.instance, self.destination,
self.block_migration, self.disk_over_commit, self.migration,
compute_rpcapi.ComputeAPI(), servicegroup.API(),
scheduler_client.SchedulerClient(), request_spec=None)
another_spec = objects.RequestSpec()
self.instance.flavor = objects.Flavor()
self.instance.numa_topology = None
self.instance.pci_requests = None
@mock.patch.object(task, '_call_livem_checks_on_host')
@mock.patch.object(task, '_check_compatible_with_source_hypervisor')
@mock.patch.object(task.scheduler_client, 'select_destinations')
@mock.patch.object(objects.RequestSpec, 'from_components')
@mock.patch.object(scheduler_utils, 'setup_instance_group')
@mock.patch.object(utils, 'get_image_from_system_metadata')
def do_test(get_image, setup_ig, from_components, select_dest,
check_compat, call_livem_checks):
get_image.return_value = "image"
from_components.return_value = another_spec
select_dest.return_value = [[fake_selection1]]
self.assertEqual(("host1", "node1"), task._find_destination())
get_image.assert_called_once_with(self.instance.system_metadata)
setup_ig.assert_called_once_with(self.context, another_spec)
self.ensure_network_metadata_mock.assert_called_once_with(
self.instance)
self.heal_reqspec_is_bfv_mock.assert_called_once_with(
self.context, another_spec, self.instance)
select_dest.assert_called_once_with(self.context, another_spec,
[self.instance.uuid], return_objects=True,
return_alternates=False)
# Make sure the request_spec was updated to include the cell
# mapping.
self.assertIsNotNone(another_spec.requested_destination.cell)
check_compat.assert_called_once_with("host1")
call_livem_checks.assert_called_once_with("host1")
do_test()
@mock.patch.object(live_migrate.LiveMigrationTask,
'_call_livem_checks_on_host')
@mock.patch.object(live_migrate.LiveMigrationTask,