From 2740ef8f31a98a9b1486af344ef8cb3399e68aa0 Mon Sep 17 00:00:00 2001 From: "Kevin L. Mitchell" Date: Fri, 27 Jul 2012 18:49:05 -0500 Subject: Fix state logic for auto-confirm resizes In the compute manager, the _poll_unconfirmed_resizes() periodic task mishandled state checks, and would call confirm_resize() in invalid states. This patch fixes the logic so that confirm_resize() is only called if the instance is in vm_state 'resized' and task_state None. The unit test is also fixed for the proper logic. Fixes bug 1030175. Change-Id: I66028b7042d88fb0f1f41df07f42b4b02cf60247 --- nova/compute/manager.py | 2 +- nova/tests/compute/test_compute.py | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 9e6407bbf..f41b20a97 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -2517,7 +2517,7 @@ class ComputeManager(manager.SchedulerDependentManager): instance=instance) continue if instance['vm_state'] != vm_states.RESIZED \ - and instance['task_state'] != None: + or instance['task_state'] is not None: state = instance['vm_state'] reason = _("In %(state)s vm_state, not RESIZED") _set_migration_to_error(migration_id, reason % locals(), diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py index ca595ee6e..40f053cc7 100644 --- a/nova/tests/compute/test_compute.py +++ b/nova/tests/compute/test_compute.py @@ -1954,16 +1954,19 @@ class ComputeTestCase(BaseTestCase): 'task_state': None}, {'uuid': 'fake_uuid3', 'vm_state': vm_states.ACTIVE, 'task_state': task_states.REBOOTING}, - {'uuid': 'fake_uuid4', 'vm_state': vm_states.ACTIVE, + {'uuid': 'fake_uuid4', 'vm_state': vm_states.RESIZED, 'task_state': None}, {'uuid': 'fake_uuid5', 'vm_state': vm_states.ACTIVE, - 'task_state': None}] + 'task_state': None}, + {'uuid': 'fake_uuid6', 'vm_state': vm_states.RESIZED, + 'task_state': 'deleting'}] expected_migration_status = {'fake_uuid1': 'confirmed', 'noexist': 'error', 'fake_uuid2': 'error', 'fake_uuid3': 'error', 'fake_uuid4': None, - 'fake_uuid5': 'confirmed'} + 'fake_uuid5': 'error', + 'fake_uuid6': 'error'} migrations = [] for i, instance in enumerate(instances, start=1): migrations.append({'id': i, -- cgit