Renaming state DELAYED to RUNNING_DELAYED

* As discussed in the mailing list it's better to rename DELAYED
  to RUNNING_DELAYED so that we semantically express it as a substate
  of RUNNING whereas WAITING is not.

Closes-Bug: #1470369
Change-Id: I3b7033d894d29fe755d4d0262c1029c4576421cd
This commit is contained in:
Renat Akhmerov 2015-09-25 15:07:28 +06:00
parent eee5296393
commit 3707062d67
6 changed files with 27 additions and 25 deletions

View File

@ -170,7 +170,7 @@ class DefaultEngine(base.Engine, coordination.Service):
task_handler.after_task_complete(task_ex, task_spec, wf_spec)
# Ignore DELAYED state.
if task_ex.state == states.DELAYED:
if task_ex.state == states.RUNNING_DELAYED:
return
wf_ctrl = wf_base.WorkflowController.get_controller(wf_ex)

View File

@ -31,7 +31,7 @@ def _log_task_delay(task_ex, delay_sec):
wf_trace.info(
task_ex,
"Task '%s' [%s -> %s, delay = %s sec]" %
(task_ex.name, task_ex.state, states.DELAYED, delay_sec)
(task_ex.name, task_ex.state, states.RUNNING_DELAYED, delay_sec)
)
@ -174,7 +174,7 @@ class WaitBeforePolicy(base.TaskPolicy):
wf_trace.info(
task_ex,
"Task '%s' [%s -> %s]"
% (task_ex.name, states.DELAYED, states.RUNNING)
% (task_ex.name, states.RUNNING_DELAYED, states.RUNNING)
)
task_ex.state = states.RUNNING
@ -185,7 +185,7 @@ class WaitBeforePolicy(base.TaskPolicy):
policy_context.update({'skip': True})
_log_task_delay(task_ex, self.delay)
task_ex.state = states.DELAYED
task_ex.state = states.RUNNING_DELAYED
scheduler.schedule_call(
None,
@ -228,7 +228,7 @@ class WaitAfterPolicy(base.TaskPolicy):
state = task_ex.state
# Set task state to 'DELAYED'.
task_ex.state = states.DELAYED
task_ex.state = states.RUNNING_DELAYED
# Schedule to change task state to RUNNING again.
scheduler.schedule_call(
@ -314,7 +314,7 @@ class RetryPolicy(base.TaskPolicy):
_log_task_delay(task_ex, self.delay)
data_flow.invalidate_task_execution_result(task_ex)
task_ex.state = states.DELAYED
task_ex.state = states.RUNNING_DELAYED
policy_context['retry_no'] = retry_no + 1
runtime_context[context_key] = policy_context

View File

@ -151,4 +151,4 @@ class EngineTestCase(base.DbTestCase):
return self.is_task_in_state(task_ex_id, states.ERROR)
def is_task_delayed(self, task_ex_id):
return self.is_task_in_state(task_ex_id, states.DELAYED)
return self.is_task_in_state(task_ex_id, states.RUNNING_DELAYED)

View File

@ -338,7 +338,7 @@ class PoliciesTest(base.EngineTestCase):
wf_ex = db_api.get_workflow_execution(wf_ex.id)
task_ex = wf_ex.task_executions[0]
self.assertEqual(states.DELAYED, task_ex.state)
self.assertEqual(states.RUNNING_DELAYED, task_ex.state)
self.assertDictEqual(
{'wait_before_policy': {'skip': True}},
task_ex.runtime_context
@ -356,7 +356,7 @@ class PoliciesTest(base.EngineTestCase):
exec_db = db_api.get_execution(exec_db.id)
task_db = exec_db.task_executions[0]
self.assertEqual(states.DELAYED, task_db.state)
self.assertEqual(states.RUNNING_DELAYED, task_db.state)
self._await(lambda: self.is_execution_success(exec_db.id))

View File

@ -29,14 +29,14 @@ class StatesModuleTest(base.BaseTest):
self.assertTrue(s.is_valid_transition(s.IDLE, s.RUNNING))
self.assertTrue(s.is_valid_transition(s.IDLE, s.ERROR))
self.assertFalse(s.is_valid_transition(s.IDLE, s.PAUSED))
self.assertFalse(s.is_valid_transition(s.IDLE, s.DELAYED))
self.assertFalse(s.is_valid_transition(s.IDLE, s.RUNNING_DELAYED))
self.assertFalse(s.is_valid_transition(s.IDLE, s.SUCCESS))
# From RUNNING
self.assertTrue(s.is_valid_transition(s.RUNNING, s.RUNNING))
self.assertTrue(s.is_valid_transition(s.RUNNING, s.ERROR))
self.assertTrue(s.is_valid_transition(s.RUNNING, s.PAUSED))
self.assertTrue(s.is_valid_transition(s.RUNNING, s.DELAYED))
self.assertTrue(s.is_valid_transition(s.RUNNING, s.RUNNING_DELAYED))
self.assertTrue(s.is_valid_transition(s.RUNNING, s.SUCCESS))
self.assertFalse(s.is_valid_transition(s.RUNNING, s.IDLE))
@ -44,31 +44,33 @@ class StatesModuleTest(base.BaseTest):
self.assertTrue(s.is_valid_transition(s.PAUSED, s.PAUSED))
self.assertTrue(s.is_valid_transition(s.PAUSED, s.RUNNING))
self.assertTrue(s.is_valid_transition(s.PAUSED, s.ERROR))
self.assertFalse(s.is_valid_transition(s.PAUSED, s.DELAYED))
self.assertFalse(s.is_valid_transition(s.PAUSED, s.RUNNING_DELAYED))
self.assertFalse(s.is_valid_transition(s.PAUSED, s.SUCCESS))
self.assertFalse(s.is_valid_transition(s.PAUSED, s.IDLE))
# From DELAYED
self.assertTrue(s.is_valid_transition(s.DELAYED, s.DELAYED))
self.assertTrue(s.is_valid_transition(s.DELAYED, s.RUNNING))
self.assertTrue(s.is_valid_transition(s.DELAYED, s.ERROR))
self.assertFalse(s.is_valid_transition(s.DELAYED, s.PAUSED))
self.assertFalse(s.is_valid_transition(s.DELAYED, s.SUCCESS))
self.assertFalse(s.is_valid_transition(s.DELAYED, s.IDLE))
self.assertTrue(
s.is_valid_transition(s.RUNNING_DELAYED, s.RUNNING_DELAYED)
)
self.assertTrue(s.is_valid_transition(s.RUNNING_DELAYED, s.RUNNING))
self.assertTrue(s.is_valid_transition(s.RUNNING_DELAYED, s.ERROR))
self.assertFalse(s.is_valid_transition(s.RUNNING_DELAYED, s.PAUSED))
self.assertFalse(s.is_valid_transition(s.RUNNING_DELAYED, s.SUCCESS))
self.assertFalse(s.is_valid_transition(s.RUNNING_DELAYED, s.IDLE))
# From SUCCESS
self.assertTrue(s.is_valid_transition(s.SUCCESS, s.SUCCESS))
self.assertFalse(s.is_valid_transition(s.SUCCESS, s.RUNNING))
self.assertFalse(s.is_valid_transition(s.SUCCESS, s.ERROR))
self.assertFalse(s.is_valid_transition(s.SUCCESS, s.PAUSED))
self.assertFalse(s.is_valid_transition(s.SUCCESS, s.DELAYED))
self.assertFalse(s.is_valid_transition(s.SUCCESS, s.RUNNING_DELAYED))
self.assertFalse(s.is_valid_transition(s.SUCCESS, s.IDLE))
# From ERROR
self.assertTrue(s.is_valid_transition(s.ERROR, s.ERROR))
self.assertTrue(s.is_valid_transition(s.ERROR, s.RUNNING))
self.assertFalse(s.is_valid_transition(s.ERROR, s.PAUSED))
self.assertFalse(s.is_valid_transition(s.ERROR, s.DELAYED))
self.assertFalse(s.is_valid_transition(s.ERROR, s.RUNNING_DELAYED))
self.assertFalse(s.is_valid_transition(s.ERROR, s.SUCCESS))
self.assertFalse(s.is_valid_transition(s.ERROR, s.IDLE))
@ -76,6 +78,6 @@ class StatesModuleTest(base.BaseTest):
self.assertTrue(s.is_valid_transition(s.WAITING, s.RUNNING))
self.assertFalse(s.is_valid_transition(s.WAITING, s.SUCCESS))
self.assertFalse(s.is_valid_transition(s.WAITING, s.PAUSED))
self.assertFalse(s.is_valid_transition(s.WAITING, s.DELAYED))
self.assertFalse(s.is_valid_transition(s.WAITING, s.RUNNING_DELAYED))
self.assertFalse(s.is_valid_transition(s.WAITING, s.IDLE))
self.assertFalse(s.is_valid_transition(s.WAITING, s.ERROR))

View File

@ -19,19 +19,19 @@
IDLE = 'IDLE'
WAITING = 'WAITING'
RUNNING = 'RUNNING'
RUNNING_DELAYED = 'DELAYED'
PAUSED = 'PAUSED'
DELAYED = 'DELAYED'
SUCCESS = 'SUCCESS'
ERROR = 'ERROR'
_ALL = [IDLE, WAITING, RUNNING, SUCCESS, ERROR, PAUSED, DELAYED]
_ALL = [IDLE, WAITING, RUNNING, SUCCESS, ERROR, PAUSED, RUNNING_DELAYED]
_VALID_TRANSITIONS = {
IDLE: [RUNNING, ERROR],
WAITING: [RUNNING],
RUNNING: [PAUSED, DELAYED, SUCCESS, ERROR],
RUNNING: [PAUSED, RUNNING_DELAYED, SUCCESS, ERROR],
RUNNING_DELAYED: [RUNNING, ERROR],
PAUSED: [RUNNING, ERROR],
DELAYED: [RUNNING, ERROR],
SUCCESS: [],
ERROR: [RUNNING]
}