diff options
| author | Wangpan <hzwangpan@corp.netease.com> | 2012-12-06 15:13:54 +0800 |
|---|---|---|
| committer | Wangpan <hzwangpan@corp.netease.com> | 2012-12-20 10:11:29 +0800 |
| commit | 9eadd4fdf4a76a9ea92790a6c4aa20d0aa32ef86 (patch) | |
| tree | a1687b093ae2c8beb8a5c7de5eb82a872e47943f /nova | |
| parent | 4e1634df7f47a181db80c709abaf60652b4a7e11 (diff) | |
| download | nova-9eadd4fdf4a76a9ea92790a6c4aa20d0aa32ef86.tar.gz nova-9eadd4fdf4a76a9ea92790a6c4aa20d0aa32ef86.tar.xz nova-9eadd4fdf4a76a9ea92790a6c4aa20d0aa32ef86.zip | |
Fix revert resize failure with disk.local not found
If we resize an instance from a flavor without ephemeral disk to a flavor
with it, it resizes OK, but if we revert this resize, the instance fail to
spawn with error disk.local not found.
The reason is that the libvirt driver get the wrong resized flavor from
instance, so the flavor info of instance should be updated before instance
spawns.
Fixes: bug #1086688
Change-Id: I2c54586803c60baab7f20297b309a8e6c4134d13
Diffstat (limited to 'nova')
| -rw-r--r-- | nova/compute/manager.py | 22 | ||||
| -rw-r--r-- | nova/tests/compute/test_compute.py | 8 |
2 files changed, 18 insertions, 12 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 7c33a8c8a..4e78e03e6 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -1720,16 +1720,21 @@ class ComputeManager(manager.SchedulerDependentManager): self._notify_about_instance_usage( context, instance, "resize.revert.start") + old_instance_type = migration['old_instance_type_id'] + instance_type = instance_types.get_instance_type(old_instance_type) + instance = self._instance_update(context, - instance['uuid'], - host=migration['source_compute'], - node=migration['source_node']) + instance['uuid'], + memory_mb=instance_type['memory_mb'], + vcpus=instance_type['vcpus'], + root_gb=instance_type['root_gb'], + ephemeral_gb=instance_type['ephemeral_gb'], + instance_type_id=instance_type['id'], + host=migration['source_compute'], + node=migration['source_node']) self.network_api.setup_networks_on_host(context, instance, migration['source_compute']) - old_instance_type = migration['old_instance_type_id'] - instance_type = instance_types.get_instance_type(old_instance_type) - bdms = self._get_instance_volume_bdms(context, instance['uuid']) block_device_info = self._get_instance_volume_block_device_info( context, instance['uuid']) @@ -1748,11 +1753,6 @@ class ComputeManager(manager.SchedulerDependentManager): # the 'old' VM already has the preferred attributes self._instance_update(context, instance['uuid'], - memory_mb=instance_type['memory_mb'], - vcpus=instance_type['vcpus'], - root_gb=instance_type['root_gb'], - ephemeral_gb=instance_type['ephemeral_gb'], - instance_type_id=instance_type['id'], launched_at=timeutils.utcnow(), expected_task_state=task_states. RESIZE_REVERTING) diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py index 079a25d27..03e627af6 100644 --- a/nova/tests/compute/test_compute.py +++ b/nova/tests/compute/test_compute.py @@ -2051,8 +2051,14 @@ class ComputeTestCase(BaseTestCase): def fake(*args, **kwargs): pass + def fake_finish_revert_migration_driver(*args, **kwargs): + # Confirm the instance uses the old type in finish_revert_resize + inst = args[0] + self.assertEqual(inst['instance_type']['flavorid'], '1') + self.stubs.Set(self.compute.driver, 'finish_migration', fake) - self.stubs.Set(self.compute.driver, 'finish_revert_migration', fake) + self.stubs.Set(self.compute.driver, 'finish_revert_migration', + fake_finish_revert_migration_driver) reservations = self._ensure_quota_reservations_committed() |
