Skip to content

Commit

Permalink
Reset task state before rescheduling
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Brian Elliott committed Sep 12, 2012
1 parent 511807e commit f5ad3bc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions nova/compute/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,11 @@ def _reschedule(self, context, instance_uuid, requested_networks,

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)
Expand Down
5 changes: 5 additions & 0 deletions nova/tests/compute/test_compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -5038,6 +5038,10 @@ def setUp(self):

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"

Expand Down Expand Up @@ -5072,6 +5076,7 @@ def test_reschedule_success(self):
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):
Expand Down

0 comments on commit f5ad3bc

Please sign in to comment.