From a413150b201dbc83865d3429c172600c1007674a Mon Sep 17 00:00:00 2001 From: Balazs Gibizer Date: Thu, 11 Apr 2019 17:50:25 +0200 Subject: [PATCH] Pass network API to the conducor's MigrationTask During migration conductor needs to heal the content of the RequestSpec.requested_resources field based on the resource requests of the ports attached to the instance being migrated. This patch makes sure that the MigrationTask has access the networking API to do such healing. blueprint: support-move-ops-with-qos-ports Change-Id: Idf38568c3c237687c54fbbfcc6c5792c49c95161 --- nova/conductor/manager.py | 2 +- nova/conductor/tasks/migrate.py | 3 ++- nova/tests/unit/conductor/tasks/test_migrate.py | 5 ++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/nova/conductor/manager.py b/nova/conductor/manager.py index 82b125cd45..74495c4888 100644 --- a/nova/conductor/manager.py +++ b/nova/conductor/manager.py @@ -485,7 +485,7 @@ class ComputeTaskManager(base.Base): request_spec, clean_shutdown, self.compute_rpcapi, self.query_client, self.report_client, - host_list) + host_list, self.network_api) def _destroy_build_request(self, context, instance): # The BuildRequest needs to be stored until the instance is mapped to diff --git a/nova/conductor/tasks/migrate.py b/nova/conductor/tasks/migrate.py index 4998c96fa9..f4803e44be 100644 --- a/nova/conductor/tasks/migrate.py +++ b/nova/conductor/tasks/migrate.py @@ -112,7 +112,7 @@ def revert_allocation_for_migration(context, source_cn, instance, migration): class MigrationTask(base.TaskBase): def __init__(self, context, instance, flavor, request_spec, clean_shutdown, compute_rpcapi, - query_client, report_client, host_list): + query_client, report_client, host_list, network_api): super(MigrationTask, self).__init__(context, instance) self.clean_shutdown = clean_shutdown self.request_spec = request_spec @@ -122,6 +122,7 @@ class MigrationTask(base.TaskBase): self.query_client = query_client self.reportclient = report_client self.host_list = host_list + self.network_api = network_api # Persist things from the happy path so we don't have to look # them up if we need to roll back diff --git a/nova/tests/unit/conductor/tasks/test_migrate.py b/nova/tests/unit/conductor/tasks/test_migrate.py index bab53361a9..0e6aae11db 100644 --- a/nova/tests/unit/conductor/tasks/test_migrate.py +++ b/nova/tests/unit/conductor/tasks/test_migrate.py @@ -60,6 +60,8 @@ class MigrationTaskTestCase(test.NoDBTestCase): self.ensure_network_metadata_mock = _p.start() self.addCleanup(_p.stop) + self.mock_network_api = mock.Mock() + def _generate_task(self): return migrate.MigrationTask(self.context, self.instance, self.flavor, self.request_spec, @@ -67,7 +69,8 @@ class MigrationTaskTestCase(test.NoDBTestCase): compute_rpcapi.ComputeAPI(), query.SchedulerQueryClient(), report.SchedulerReportClient(), - host_list=None) + host_list=None, + network_api=self.mock_network_api) @mock.patch.object(objects.MigrationList, 'get_by_filters') @mock.patch('nova.scheduler.client.report.SchedulerReportClient')