Skip to content

Commit

Permalink
Fix status transition when reverting resize
Browse files Browse the repository at this point in the history
Present the instance being reverted with a 'REVERT_RESIZE' status instead
of 'ACTIVE' after a revertResize action is triggered. Fixes bug 924371

Change-Id: I12e98733fd00c0794fb9a4acb0cc6752ca02e855
  • Loading branch information
bcwaldon committed Feb 3, 2012
1 parent f0a1148 commit f7deddb
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions nova/api/openstack/common.py
Expand Up @@ -66,6 +66,7 @@
},
vm_states.RESIZING: {
'default': 'RESIZE',
task_states.RESIZE_REVERTING: 'REVERT_RESIZE',
},
vm_states.PAUSED: {
'default': 'PAUSED',
Expand Down
4 changes: 2 additions & 2 deletions nova/compute/api.py
Expand Up @@ -1327,8 +1327,8 @@ def revert_resize(self, context, instance):

self.update(context,
instance,
vm_state=vm_states.ACTIVE,
task_state=None)
vm_state=vm_states.RESIZING,
task_state=task_states.RESIZE_REVERTING)

params = {'migration_id': migration_ref['id']}
self._cast_compute_message('revert_resize', context,
Expand Down
4 changes: 3 additions & 1 deletion nova/compute/manager.py
Expand Up @@ -1168,7 +1168,9 @@ def finish_revert_resize(self, context, instance_uuid, migration_id):
vcpus=instance_type['vcpus'],
root_gb=instance_type['root_gb'],
ephemeral_gb=instance_type['ephemeral_gb'],
instance_type_id=instance_type['id'])
instance_type_id=instance_type['id'],
vm_state=vm_states.ACTIVE,
task_state=None)

self.driver.finish_revert_migration(instance_ref)
self.db.migration_update(context, migration_id,
Expand Down
5 changes: 5 additions & 0 deletions nova/tests/api/openstack/compute/test_servers.py
Expand Up @@ -1376,6 +1376,11 @@ def test_verify_resize(self):
task_states.RESIZE_VERIFY)
self.assertEqual(response['server']['status'], 'VERIFY_RESIZE')

def test_revert_resize(self):
response = self._get_with_state(vm_states.RESIZING,
task_states.RESIZE_REVERTING)
self.assertEqual(response['server']['status'], 'REVERT_RESIZE')

def test_password_update(self):
response = self._get_with_state(vm_states.ACTIVE,
task_states.UPDATING_PASSWORD)
Expand Down
9 changes: 9 additions & 0 deletions nova/tests/test_compute.py
Expand Up @@ -1169,6 +1169,10 @@ def fake(*args, **kwargs):
self.compute.finish_revert_resize(context, inst_ref['uuid'],
migration_ref['id'])

instance = db.instance_get_by_uuid(context, instance['uuid'])
self.assertEqual(instance['vm_state'], vm_states.ACTIVE)
self.assertEqual(instance['task_state'], None)

inst_ref = db.instance_get_by_uuid(context, instance_uuid)
instance_type_ref = db.instance_type_get(context,
inst_ref['instance_type_id'])
Expand Down Expand Up @@ -2182,6 +2186,11 @@ def test_resize_revert_through_api(self):
instance = db.instance_get_by_uuid(context, instance['uuid'])

self.compute_api.revert_resize(context, instance)

instance = db.instance_get_by_uuid(context, instance['uuid'])
self.assertEqual(instance['vm_state'], vm_states.RESIZING)
self.assertEqual(instance['task_state'], task_states.RESIZE_REVERTING)

self.compute.terminate_instance(context, instance['uuid'])

def test_resize_invalid_flavor_fails(self):
Expand Down

0 comments on commit f7deddb

Please sign in to comment.