diff options
author | Dan Smith <danms@us.ibm.com> | 2013-02-28 17:04:11 -0500 |
---|---|---|
committer | Dan Smith <danms@us.ibm.com> | 2013-02-28 18:26:28 -0500 |
commit | 8858d4856e27f70638161633a983b5d123b04832 (patch) | |
tree | d58063cb4e31f22c2358aae7a7bc66a33a31164d | |
parent | b58bd0cd9a6ecb960a7c833d1f4857629ed1ab05 (diff) | |
download | nova-8858d4856e27f70638161633a983b5d123b04832.tar.gz nova-8858d4856e27f70638161633a983b5d123b04832.tar.xz nova-8858d4856e27f70638161633a983b5d123b04832.zip |
Don't use instance['instance_type'] for scheduler filters in migration
Instead, pull a fresh copy from the database, which has the proper
extra_specs cleanup which everyone downstream of us expects.
Fixes bug 1136430
Change-Id: Ifcb9feff8291096eed7c198b8e7a35c3c38ca93e
-rw-r--r-- | nova/scheduler/driver.py | 4 | ||||
-rw-r--r-- | nova/tests/scheduler/test_scheduler.py | 8 |
2 files changed, 11 insertions, 1 deletions
diff --git a/nova/scheduler/driver.py b/nova/scheduler/driver.py index accdead2d..3426c484c 100644 --- a/nova/scheduler/driver.py +++ b/nova/scheduler/driver.py @@ -256,9 +256,11 @@ class Scheduler(object): # If dest is not specified, have scheduler pick one. if dest is None: + instance_type = db.instance_type_get( + context, instance_ref['instance_type_id']) image = self.image_service.show(context, instance_ref['image_ref']) request_spec = {'instance_properties': instance_ref, - 'instance_type': instance_ref['instance_type'], + 'instance_type': instance_type, 'instance_uuids': [instance_ref['uuid']], 'image': image} filter_properties = {'ignore_hosts': ignore_hosts} diff --git a/nova/tests/scheduler/test_scheduler.py b/nova/tests/scheduler/test_scheduler.py index 5d0228c62..4e95061a7 100644 --- a/nova/tests/scheduler/test_scheduler.py +++ b/nova/tests/scheduler/test_scheduler.py @@ -403,6 +403,7 @@ class SchedulerTestCase(test.TestCase): 'vm_state': '', 'task_state': '', 'instance_type': {'memory_mb': 1024}, + 'instance_type_id': 1, 'image_ref': 'fake-image-ref'} def test_live_migration_basic(self): @@ -736,6 +737,7 @@ class SchedulerTestCase(test.TestCase): def test_live_migration_dest_check_auto_set_host(self): # Confirm dest is picked by scheduler if not set. self.mox.StubOutWithMock(self.driver, 'select_hosts') + self.mox.StubOutWithMock(db, 'instance_type_get') instance = self._live_migration_instance() request_spec = {'instance_properties': instance, @@ -747,6 +749,8 @@ class SchedulerTestCase(test.TestCase): ignore_hosts = [instance['host']] filter_properties = {'ignore_hosts': ignore_hosts} + db.instance_type_get(self.context, 1).AndReturn( + instance['instance_type']) self.driver.select_hosts(self.context, request_spec, filter_properties).AndReturn(['fake_host2']) @@ -757,6 +761,7 @@ class SchedulerTestCase(test.TestCase): def test_live_migration_auto_set_dest(self): # Confirm scheduler picks target host if none given. + self.mox.StubOutWithMock(db, 'instance_type_get') self.mox.StubOutWithMock(self.driver, '_live_migration_src_check') self.mox.StubOutWithMock(self.driver, 'select_hosts') self.mox.StubOutWithMock(self.driver, '_live_migration_common_check') @@ -776,6 +781,9 @@ class SchedulerTestCase(test.TestCase): self.driver._live_migration_src_check(self.context, instance) + db.instance_type_get(self.context, 1).MultipleTimes().AndReturn( + instance['instance_type']) + # First selected host raises exception.InvalidHypervisorType self.driver.select_hosts(self.context, request_spec, {'ignore_hosts': [instance['host']]}).AndReturn(['fake_host2']) |