diff options
| author | Dan Smith <danms@us.ibm.com> | 2013-03-26 13:14:56 -0700 |
|---|---|---|
| committer | Dan Smith <danms@us.ibm.com> | 2013-03-26 13:14:56 -0700 |
| commit | 985d703d2731fe9ec968ef6698bbf39743ede32a (patch) | |
| tree | 9a2d715abd8292780ce80a157c1609f83a4c6170 /nova/compute | |
| parent | 2900258d5e117afd302ecff3411658910078d431 (diff) | |
Always store old instance_type during a migration
Previously, we were trying to optimize for the migration (as opposed
to resize) case by not storing the old_ instance_type. However,
this is confusing to the vast amount of shared code that works on
migrations and resizes because the "is old == new" logic must be
replicated everywhere. To cut our losses and hopefully avoid other
hidden dragons, this patch removes the optimization and makes both
paths the same.
Fixes bug #1160489
Change-Id: I2ad7b02239baada5fd2174f5b61cdc90ec91e6f5
Diffstat (limited to 'nova/compute')
| -rwxr-xr-x | nova/compute/manager.py | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 8798e4aee..6cb0bbb94 100755 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -1989,11 +1989,8 @@ class ComputeManager(manager.SchedulerDependentManager): Returns the updated system_metadata as a dict, as well as the post-cleanup current instance type. """ - same_type = (migration['old_instance_type_id'] == - migration['new_instance_type_id']) - sys_meta = utils.metadata_to_dict(instance['system_metadata']) - if restore_old and not same_type: + if restore_old: instance_type = instance_types.extract_instance_type(instance, 'old_') sys_meta = instance_types.save_instance_type_info(sys_meta, @@ -2001,10 +1998,7 @@ class ComputeManager(manager.SchedulerDependentManager): else: instance_type = instance_types.extract_instance_type(instance) - if not same_type: - instance_types.delete_instance_type_info(sys_meta, 'old_') - - # NOTE(danms): new instance type is always stored in prep_resize + instance_types.delete_instance_type_info(sys_meta, 'old_') instance_types.delete_instance_type_info(sys_meta, 'new_') return sys_meta, instance_type @@ -2380,14 +2374,14 @@ class ComputeManager(manager.SchedulerDependentManager): resize_instance = False old_instance_type_id = migration['old_instance_type_id'] new_instance_type_id = migration['new_instance_type_id'] + old_instance_type = instance_types.extract_instance_type(instance) + sys_meta = utils.metadata_to_dict(instance['system_metadata']) + instance_types.save_instance_type_info(sys_meta, + old_instance_type, + prefix='old_') if old_instance_type_id != new_instance_type_id: instance_type = instance_types.extract_instance_type(instance, prefix='new_') - old_instance_type = instance_types.extract_instance_type(instance) - sys_meta = utils.metadata_to_dict(instance['system_metadata']) - instance_types.save_instance_type_info(sys_meta, - old_instance_type, - prefix='old_') instance_types.save_instance_type_info(sys_meta, instance_type) instance = self._instance_update( @@ -2398,7 +2392,7 @@ class ComputeManager(manager.SchedulerDependentManager): vcpus=instance_type['vcpus'], root_gb=instance_type['root_gb'], ephemeral_gb=instance_type['ephemeral_gb'], - system_metadata=sys_meta) + system_metadata=dict(sys_meta)) resize_instance = True @@ -2414,7 +2408,8 @@ class ComputeManager(manager.SchedulerDependentManager): instance = self._instance_update(context, instance['uuid'], task_state=task_states.RESIZE_FINISH, - expected_task_state=task_states.RESIZE_MIGRATED) + expected_task_state=task_states.RESIZE_MIGRATED, + system_metadata=sys_meta) self._notify_about_instance_usage( context, instance, "finish_resize.start", |
