summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Elliott <brian.elliott@rackspace.com>2012-09-12 00:49:07 +0000
committerBrian Elliott <brian.elliott@rackspace.com>2012-09-12 01:28:05 +0000
commitf5ad3bced3788fea89a4a25a29053d51aeb7a3b2 (patch)
treef0e9d8a730ee1cc03b5e38230ac0ee3ea117b290
parent511807ed248fbe63cb6642c1cff6e0bd4bb8ae5d (diff)
Reset task state before rescheduling
Reset the task state to SCHEDULING before attempting re-scheduling. This is a precaution to make sure subsequent calls to update the task state see an 'expected_task_state'. bug 1049897 Change-Id: I5667a88487bd7039eb2e0aaebef532199d8b31ef
-rw-r--r--nova/compute/manager.py5
-rw-r--r--nova/tests/compute/test_compute.py5
2 files changed, 10 insertions, 0 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index 9fc3104d0..3ad68176b 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -569,6 +569,11 @@ class ComputeManager(manager.SchedulerDependentManager):
LOG.debug(_("Re-scheduling instance: attempt %d"),
retry['num_attempts'], instance_uuid=instance_uuid)
+
+ # reset the task state:
+ self._instance_update(context, instance_uuid,
+ task_state=task_states.SCHEDULING)
+
self.scheduler_rpcapi.run_instance(context,
request_spec, admin_password, injected_files,
requested_networks, is_first_time, filter_properties)
diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py
index f47a5b99d..27fd90146 100644
--- a/nova/tests/compute/test_compute.py
+++ b/nova/tests/compute/test_compute.py
@@ -5038,6 +5038,10 @@ class ComputeReschedulingTestCase(BaseTestCase):
self._reschedule = self._reschedule_partial()
+ def fake_update(*args, **kwargs):
+ self.updated_task_state = kwargs.get('task_state')
+ self.stubs.Set(self.compute, '_instance_update', fake_update)
+
def _reschedule_partial(self):
uuid = "12-34-56-78-90"
@@ -5072,6 +5076,7 @@ class ComputeReschedulingTestCase(BaseTestCase):
self.assertTrue(self._reschedule(filter_properties=filter_properties,
request_spec=request_spec))
self.assertEqual(1, len(request_spec['instance_uuids']))
+ self.assertEqual(self.updated_task_state, task_states.SCHEDULING)
class ThatsNoOrdinaryRabbitException(Exception):