summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-02-09 01:44:02 +0000
committerGerrit Code Review <review@openstack.org>2018-02-09 01:44:02 +0000
commit5caca24dc79e3942b26e00ff1e0b8e7a320a947f (patch)
treedc4c43d418ce2c73ee9b173e1dd72794224deac5
parentfaf0736a067223e82be5c0f9c5a8e5f74ff80b2f (diff)
parent26335270bf528a2b9c48c976110c1672137df336 (diff)
Merge "Clean up reservations in migrate_task call path"17.0.0.0rc1
-rw-r--r--nova/conductor/manager.py12
-rw-r--r--nova/conductor/tasks/migrate.py3
-rw-r--r--nova/tests/unit/conductor/tasks/test_migrate.py2
-rw-r--r--nova/tests/unit/conductor/test_conductor.py21
4 files changed, 16 insertions, 22 deletions
diff --git a/nova/conductor/manager.py b/nova/conductor/manager.py
index 98efa23..f032742 100644
--- a/nova/conductor/manager.py
+++ b/nova/conductor/manager.py
@@ -239,6 +239,8 @@ class ComputeTaskManager(base.Base):
239 239
240 # TODO(tdurakov): remove `live` parameter here on compute task api RPC 240 # TODO(tdurakov): remove `live` parameter here on compute task api RPC
241 # version bump to 2.x 241 # version bump to 2.x
242 # TODO(danms): remove the `reservations` parameter here on compute task api
243 # RPC version bump to 2.x
242 @messaging.expected_exceptions( 244 @messaging.expected_exceptions(
243 exception.NoValidHost, 245 exception.NoValidHost,
244 exception.ComputeServiceUnavailable, 246 exception.ComputeServiceUnavailable,
@@ -282,13 +284,13 @@ class ComputeTaskManager(base.Base):
282 instance_uuid): 284 instance_uuid):
283 self._cold_migrate(context, instance, flavor, 285 self._cold_migrate(context, instance, flavor,
284 scheduler_hint['filter_properties'], 286 scheduler_hint['filter_properties'],
285 reservations, clean_shutdown, request_spec, 287 clean_shutdown, request_spec,
286 host_list) 288 host_list)
287 else: 289 else:
288 raise NotImplementedError() 290 raise NotImplementedError()
289 291
290 def _cold_migrate(self, context, instance, flavor, filter_properties, 292 def _cold_migrate(self, context, instance, flavor, filter_properties,
291 reservations, clean_shutdown, request_spec, host_list): 293 clean_shutdown, request_spec, host_list):
292 image = utils.get_image_from_system_metadata( 294 image = utils.get_image_from_system_metadata(
293 instance.system_metadata) 295 instance.system_metadata)
294 296
@@ -309,7 +311,7 @@ class ComputeTaskManager(base.Base):
309 request_spec.flavor = flavor 311 request_spec.flavor = flavor
310 312
311 task = self._build_cold_migrate_task(context, instance, flavor, 313 task = self._build_cold_migrate_task(context, instance, flavor,
312 request_spec, reservations, clean_shutdown, host_list) 314 request_spec, clean_shutdown, host_list)
313 try: 315 try:
314 task.execute() 316 task.execute()
315 except exception.NoValidHost as ex: 317 except exception.NoValidHost as ex:
@@ -463,10 +465,10 @@ class ComputeTaskManager(base.Base):
463 request_spec) 465 request_spec)
464 466
465 def _build_cold_migrate_task(self, context, instance, flavor, request_spec, 467 def _build_cold_migrate_task(self, context, instance, flavor, request_spec,
466 reservations, clean_shutdown, host_list): 468 clean_shutdown, host_list):
467 return migrate.MigrationTask(context, instance, flavor, 469 return migrate.MigrationTask(context, instance, flavor,
468 request_spec, 470 request_spec,
469 reservations, clean_shutdown, 471 clean_shutdown,
470 self.compute_rpcapi, 472 self.compute_rpcapi,
471 self.scheduler_client, host_list) 473 self.scheduler_client, host_list)
472 474
diff --git a/nova/conductor/tasks/migrate.py b/nova/conductor/tasks/migrate.py
index 45ff3b3..3a65437 100644
--- a/nova/conductor/tasks/migrate.py
+++ b/nova/conductor/tasks/migrate.py
@@ -110,12 +110,11 @@ def should_do_migration_allocation(context):
110 110
111class MigrationTask(base.TaskBase): 111class MigrationTask(base.TaskBase):
112 def __init__(self, context, instance, flavor, 112 def __init__(self, context, instance, flavor,
113 request_spec, reservations, clean_shutdown, compute_rpcapi, 113 request_spec, clean_shutdown, compute_rpcapi,
114 scheduler_client, host_list): 114 scheduler_client, host_list):
115 super(MigrationTask, self).__init__(context, instance) 115 super(MigrationTask, self).__init__(context, instance)
116 self.clean_shutdown = clean_shutdown 116 self.clean_shutdown = clean_shutdown
117 self.request_spec = request_spec 117 self.request_spec = request_spec
118 self.reservations = reservations
119 self.flavor = flavor 118 self.flavor = flavor
120 119
121 self.compute_rpcapi = compute_rpcapi 120 self.compute_rpcapi = compute_rpcapi
diff --git a/nova/tests/unit/conductor/tasks/test_migrate.py b/nova/tests/unit/conductor/tasks/test_migrate.py
index 968ce37..0d4957f 100644
--- a/nova/tests/unit/conductor/tasks/test_migrate.py
+++ b/nova/tests/unit/conductor/tasks/test_migrate.py
@@ -53,7 +53,7 @@ class MigrationTaskTestCase(test.NoDBTestCase):
53 53
54 def _generate_task(self): 54 def _generate_task(self):
55 return migrate.MigrationTask(self.context, self.instance, self.flavor, 55 return migrate.MigrationTask(self.context, self.instance, self.flavor,
56 self.request_spec, self.reservations, 56 self.request_spec,
57 self.clean_shutdown, 57 self.clean_shutdown,
58 compute_rpcapi.ComputeAPI(), 58 compute_rpcapi.ComputeAPI(),
59 scheduler_client.SchedulerClient(), 59 scheduler_client.SchedulerClient(),
diff --git a/nova/tests/unit/conductor/test_conductor.py b/nova/tests/unit/conductor/test_conductor.py
index a7c82ee..4a69918 100644
--- a/nova/tests/unit/conductor/test_conductor.py
+++ b/nova/tests/unit/conductor/test_conductor.py
@@ -2186,7 +2186,6 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase):
2186 pci_requests=None, 2186 pci_requests=None,
2187 numa_topology=None, 2187 numa_topology=None,
2188 project_id=self.context.project_id) 2188 project_id=self.context.project_id)
2189 resvs = 'fake-resvs'
2190 image = 'fake-image' 2189 image = 'fake-image'
2191 fake_spec = objects.RequestSpec(image=objects.ImageMeta()) 2190 fake_spec = objects.RequestSpec(image=objects.ImageMeta())
2192 spec_fc_mock.return_value = fake_spec 2191 spec_fc_mock.return_value = fake_spec
@@ -2203,7 +2202,7 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase):
2203 self.assertRaises(exc.NoValidHost, 2202 self.assertRaises(exc.NoValidHost,
2204 self.conductor._cold_migrate, 2203 self.conductor._cold_migrate,
2205 self.context, inst_obj, 2204 self.context, inst_obj,
2206 flavor, {}, [resvs], 2205 flavor, {},
2207 True, None, None) 2206 True, None, None)
2208 metadata_mock.assert_called_with({}) 2207 metadata_mock.assert_called_with({})
2209 sig_mock.assert_called_once_with(self.context, fake_spec) 2208 sig_mock.assert_called_once_with(self.context, fake_spec)
@@ -2238,7 +2237,6 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase):
2238 availability_zone=None, 2237 availability_zone=None,
2239 project_id=self.context.project_id) 2238 project_id=self.context.project_id)
2240 image = 'fake-image' 2239 image = 'fake-image'
2241 resvs = 'fake-resvs'
2242 2240
2243 fake_spec = objects.RequestSpec(image=objects.ImageMeta()) 2241 fake_spec = objects.RequestSpec(image=objects.ImageMeta())
2244 spec_fc_mock.return_value = fake_spec 2242 spec_fc_mock.return_value = fake_spec
@@ -2255,7 +2253,7 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase):
2255 self.assertRaises(exc.NoValidHost, 2253 self.assertRaises(exc.NoValidHost,
2256 self.conductor._cold_migrate, 2254 self.conductor._cold_migrate,
2257 self.context, inst_obj, 2255 self.context, inst_obj,
2258 flavor, {}, [resvs], 2256 flavor, {},
2259 True, None, None) 2257 True, None, None)
2260 metadata_mock.assert_called_with({}) 2258 metadata_mock.assert_called_with({})
2261 sig_mock.assert_called_once_with(self.context, fake_spec) 2259 sig_mock.assert_called_once_with(self.context, fake_spec)
@@ -2275,7 +2273,6 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase):
2275 uuid=uuids.instance, 2273 uuid=uuids.instance,
2276 user_id=fakes.FAKE_USER_ID) 2274 user_id=fakes.FAKE_USER_ID)
2277 fake_spec = fake_request_spec.fake_spec_obj() 2275 fake_spec = fake_request_spec.fake_spec_obj()
2278 resvs = 'fake-resvs'
2279 image = 'fake-image' 2276 image = 'fake-image'
2280 2277
2281 with test.nested( 2278 with test.nested(
@@ -2290,7 +2287,7 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase):
2290 task_rollback_mock): 2287 task_rollback_mock):
2291 nvh = self.assertRaises(exc.NoValidHost, 2288 nvh = self.assertRaises(exc.NoValidHost,
2292 self.conductor._cold_migrate, self.context, 2289 self.conductor._cold_migrate, self.context,
2293 inst_obj, flavor, {}, [resvs], 2290 inst_obj, flavor, {},
2294 True, fake_spec, None) 2291 True, fake_spec, None)
2295 self.assertIn('cold migrate', nvh.message) 2292 self.assertIn('cold migrate', nvh.message)
2296 2293
@@ -2318,7 +2315,6 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase):
2318 numa_topology=None, 2315 numa_topology=None,
2319 pci_requests=None, 2316 pci_requests=None,
2320 availability_zone=None) 2317 availability_zone=None)
2321 resvs = 'fake-resvs'
2322 image = 'fake-image' 2318 image = 'fake-image'
2323 exception = exc.UnsupportedPolicyException(reason='') 2319 exception = exc.UnsupportedPolicyException(reason='')
2324 fake_spec = fake_request_spec.fake_spec_obj() 2320 fake_spec = fake_request_spec.fake_spec_obj()
@@ -2329,7 +2325,7 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase):
2329 2325
2330 self.assertRaises(exc.UnsupportedPolicyException, 2326 self.assertRaises(exc.UnsupportedPolicyException,
2331 self.conductor._cold_migrate, self.context, 2327 self.conductor._cold_migrate, self.context,
2332 inst_obj, flavor, {}, [resvs], True, None, None) 2328 inst_obj, flavor, {}, True, None, None)
2333 2329
2334 updates = {'vm_state': vm_states.STOPPED, 'task_state': None} 2330 updates = {'vm_state': vm_states.STOPPED, 'task_state': None}
2335 set_vm_mock.assert_called_once_with(self.context, inst_obj.uuid, 2331 set_vm_mock.assert_called_once_with(self.context, inst_obj.uuid,
@@ -2363,7 +2359,6 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase):
2363 numa_topology=None, 2359 numa_topology=None,
2364 project_id=self.context.project_id) 2360 project_id=self.context.project_id)
2365 image = 'fake-image' 2361 image = 'fake-image'
2366 resvs = 'fake-resvs'
2367 fake_spec = objects.RequestSpec(image=objects.ImageMeta()) 2362 fake_spec = objects.RequestSpec(image=objects.ImageMeta())
2368 legacy_request_spec = fake_spec.to_legacy_request_spec_dict() 2363 legacy_request_spec = fake_spec.to_legacy_request_spec_dict()
2369 spec_fc_mock.return_value = fake_spec 2364 spec_fc_mock.return_value = fake_spec
@@ -2383,7 +2378,7 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase):
2383 self.assertRaises(test.TestingException, 2378 self.assertRaises(test.TestingException,
2384 self.conductor._cold_migrate, 2379 self.conductor._cold_migrate,
2385 self.context, inst_obj, flavor, 2380 self.context, inst_obj, flavor,
2386 {}, [resvs], True, None, None) 2381 {}, True, None, None)
2387 2382
2388 # Filter properties are populated during code execution 2383 # Filter properties are populated during code execution
2389 legacy_filter_props = {'retry': {'num_attempts': 1, 2384 legacy_filter_props = {'retry': {'num_attempts': 1,
@@ -2425,7 +2420,6 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase):
2425 availability_zone=None, 2420 availability_zone=None,
2426 pci_requests=None, 2421 pci_requests=None,
2427 numa_topology=None) 2422 numa_topology=None)
2428 resvs = 'fake-resvs'
2429 image = 'fake-image' 2423 image = 'fake-image'
2430 fake_spec = fake_request_spec.fake_spec_obj() 2424 fake_spec = fake_request_spec.fake_spec_obj()
2431 2425
@@ -2434,7 +2428,7 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase):
2434 # the new one 2428 # the new one
2435 self.assertNotEqual(flavor, fake_spec.flavor) 2429 self.assertNotEqual(flavor, fake_spec.flavor)
2436 self.conductor._cold_migrate(self.context, inst_obj, flavor, {}, 2430 self.conductor._cold_migrate(self.context, inst_obj, flavor, {},
2437 [resvs], True, fake_spec, None) 2431 True, fake_spec, None)
2438 2432
2439 # Now the RequestSpec should be updated... 2433 # Now the RequestSpec should be updated...
2440 self.assertEqual(flavor, fake_spec.flavor) 2434 self.assertEqual(flavor, fake_spec.flavor)
@@ -2453,7 +2447,6 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase):
2453 user_id=fakes.FAKE_USER_ID) 2447 user_id=fakes.FAKE_USER_ID)
2454 2448
2455 fake_spec = fake_request_spec.fake_spec_obj() 2449 fake_spec = fake_request_spec.fake_spec_obj()
2456 resvs = 'fake-resvs'
2457 image = 'fake-image' 2450 image = 'fake-image'
2458 2451
2459 with test.nested( 2452 with test.nested(
@@ -2471,7 +2464,7 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase):
2471 nvh = self.assertRaises(exc.NoValidHost, 2464 nvh = self.assertRaises(exc.NoValidHost,
2472 self.conductor._cold_migrate, self.context, 2465 self.conductor._cold_migrate, self.context,
2473 inst_obj, flavor_new, {}, 2466 inst_obj, flavor_new, {},
2474 [resvs], True, fake_spec, None) 2467 True, fake_spec, None)
2475 self.assertIn('resize', nvh.message) 2468 self.assertIn('resize', nvh.message)
2476 2469
2477 @mock.patch('nova.objects.BuildRequest.get_by_instance_uuid') 2470 @mock.patch('nova.objects.BuildRequest.get_by_instance_uuid')