Skip to content

Commit

Permalink
Merge 66c366e into 9c69d97
Browse files Browse the repository at this point in the history
  • Loading branch information
m4dcoder committed Jan 9, 2016
2 parents 9c69d97 + 66c366e commit 0925a7a
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 40 deletions.
14 changes: 8 additions & 6 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ in development
(new-feature)
* Include ref of the most meaningful object in each trace component. (new-feature)
* Ability to hide trigger-instance that do not yield a rule enforcement. (new-feature)
* Change the rule list columns in the CLI from ref, pack, description and enabled to ref, trigger.ref,
action.ref and enabled. This aligns closer the UI and also brings important information front and
center. (improvement)
* Change the rule list columns in the CLI from ref, pack, description and enabled to ref,
trigger.ref, action.ref and enabled. This aligns closer the UI and also brings important
information front and center. (improvement)
* Action and Trigger filters for rule list (new-feature)
* Add missing logrotate config entry for ``st2auth`` service. #2294 [Vignesh Terafast]
* Support for object already present in the DB for ``st2-rule-tester`` (improvement)
Expand All @@ -28,8 +28,8 @@ in development
instance of ``Mock`` class which allows user to assert that a particular message has been
logged. [Tim Ireland, Tomaz Muraus]
* Introduce a new ``abandoned`` state that is applied to executions that we cannot guarantee as
completed. Typically happen when an actionrunner currently running some executions quits or is killed
via TERM.
completed. Typically happen when an actionrunner currently running some executions quits or is
killed via TERM.
* Add new ``st2garbagecollector`` service which periodically deletes old data from the database
as configured in the config. By default, no old data is deleted unless explicitly configured in
the config.
Expand All @@ -41,8 +41,10 @@ in development
execution. (bug fix)
* Deprecated ``params`` action attribute in the action chain definition in favor of the new
``parameters`` attribute. (improvement)
* Fix action parameters validation so that only a selected set of attributes can be overriden for any runner parameters. (bug fix)
* Fix action parameters validation so that only a selected set of attributes can be overriden for
any runner parameters. (bug fix)
* Fix type in the headers parameter for the http-request runner. (bug fix)
* Fix runaway action triggers caused by state miscalculation for mistral workflow. (bug fix)

1.2.0 - December 07, 2015
-------------------------
Expand Down
11 changes: 5 additions & 6 deletions st2actions/st2actions/query/mistral/v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,12 @@ def _determine_execution_status(self, execution_id, wf_state, tasks):
# Identify the list of tasks that are not in completed states.
active_tasks = [t for t in tasks if t['state'] not in DONE_STATES]

# On cancellation, mistral workflow executions are paused so that tasks can
# gracefully reach completion. If any task is not completed, do not mark st2
# action execution for the workflow complete. By marking the st2 action execution
# as running, this will keep the query for this mistral workflow execution active.
if wf_state not in DONE_STATES and not active_tasks and is_action_canceled:
# On cancellation, mistral workflow executions are paused so that tasks
# can gracefully reach completion. This is only temporary until a canceled
# status is added to mistral.
if (wf_state in DONE_STATES or wf_state == 'PAUSED') and is_action_canceled:
status = action_constants.LIVEACTION_STATUS_CANCELED
elif wf_state in DONE_STATES and active_tasks:
elif wf_state in DONE_STATES and not is_action_canceled and active_tasks:
status = action_constants.LIVEACTION_STATUS_RUNNING
elif wf_state not in DONE_STATES:
status = action_constants.LIVEACTION_STATUS_RUNNING
Expand Down
82 changes: 54 additions & 28 deletions st2actions/tests/unit/test_mistral_querier_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,72 +115,98 @@ def setUp(self):
action_service, 'is_action_canceled_or_canceling',
mock.MagicMock(return_value=False))
def test_determine_status_wf_running_tasks_running(self):
status = self.querier._determine_execution_status(uuid.uuid4().hex,
'RUNNING',
MOCK_WF_TASKS_RUNNING)

wf_id = uuid.uuid4().hex
status = self.querier._determine_execution_status(wf_id, 'RUNNING', MOCK_WF_TASKS_RUNNING)
self.assertEqual(action_constants.LIVEACTION_STATUS_RUNNING, status)

@mock.patch.object(
action_service, 'is_action_canceled_or_canceling',
mock.MagicMock(return_value=False))
def test_determine_status_wf_running_tasks_completed(self):
status = self.querier._determine_execution_status(uuid.uuid4().hex,
'RUNNING',
MOCK_WF_TASKS_SUCCEEDED)

wf_id = uuid.uuid4().hex
status = self.querier._determine_execution_status(wf_id, 'RUNNING', MOCK_WF_TASKS_SUCCEEDED)
self.assertEqual(action_constants.LIVEACTION_STATUS_RUNNING, status)

@mock.patch.object(
action_service, 'is_action_canceled_or_canceling',
mock.MagicMock(return_value=False))
def test_determine_status_wf_succeeded_tasks_completed(self):
status = self.querier._determine_execution_status(uuid.uuid4().hex,
'SUCCESS',
MOCK_WF_TASKS_SUCCEEDED)

wf_id = uuid.uuid4().hex
status = self.querier._determine_execution_status(wf_id, 'SUCCESS', MOCK_WF_TASKS_SUCCEEDED)
self.assertEqual(action_constants.LIVEACTION_STATUS_SUCCEEDED, status)

@mock.patch.object(
action_service, 'is_action_canceled_or_canceling',
mock.MagicMock(return_value=False))
def test_determine_status_wf_succeeded_tasks_running(self):
status = self.querier._determine_execution_status(uuid.uuid4().hex,
'SUCCESS',
MOCK_WF_TASKS_RUNNING)

wf_id = uuid.uuid4().hex
status = self.querier._determine_execution_status(wf_id, 'SUCCESS', MOCK_WF_TASKS_RUNNING)
self.assertEqual(action_constants.LIVEACTION_STATUS_RUNNING, status)

@mock.patch.object(
action_service, 'is_action_canceled_or_canceling',
mock.MagicMock(return_value=False))
def test_determine_status_wf_errored_tasks_completed(self):
status = self.querier._determine_execution_status(uuid.uuid4().hex,
'ERROR',
MOCK_WF_TASKS_SUCCEEDED)

wf_id = uuid.uuid4().hex
status = self.querier._determine_execution_status(wf_id, 'ERROR', MOCK_WF_TASKS_SUCCEEDED)
self.assertEqual(action_constants.LIVEACTION_STATUS_FAILED, status)

@mock.patch.object(
action_service, 'is_action_canceled_or_canceling',
mock.MagicMock(return_value=False))
def test_determine_status_wf_errored_tasks_running(self):
status = self.querier._determine_execution_status(uuid.uuid4().hex,
'ERROR',
MOCK_WF_TASKS_RUNNING)

wf_id = uuid.uuid4().hex
status = self.querier._determine_execution_status(wf_id, 'ERROR', MOCK_WF_TASKS_RUNNING)
self.assertEqual(action_constants.LIVEACTION_STATUS_RUNNING, status)

@mock.patch.object(
action_service, 'is_action_canceled_or_canceling',
mock.MagicMock(return_value=True))
def test_determine_status_wf_incomplete_tasks_completed_exec_canceled(self):
status = self.querier._determine_execution_status(uuid.uuid4().hex,
'PAUSED',
MOCK_WF_TASKS_SUCCEEDED)
def test_determine_status_wf_canceled_tasks_completed(self):
wf_id = uuid.uuid4().hex
status = self.querier._determine_execution_status(wf_id, 'PAUSED', MOCK_WF_TASKS_SUCCEEDED)
self.assertEqual(action_constants.LIVEACTION_STATUS_CANCELED, status)

@mock.patch.object(
action_service, 'is_action_canceled_or_canceling',
mock.MagicMock(return_value=True))
def test_determine_status_wf_canceled_tasks_running(self):
wf_id = uuid.uuid4().hex
status = self.querier._determine_execution_status(wf_id, 'PAUSED', MOCK_WF_TASKS_RUNNING)
self.assertEqual(action_constants.LIVEACTION_STATUS_CANCELED, status)

@mock.patch.object(
action_service, 'is_action_canceled_or_canceling',
mock.MagicMock(return_value=True))
def test_determine_status_wf_canceled_exec_running_tasks_completed(self):
wf_id = uuid.uuid4().hex
status = self.querier._determine_execution_status(wf_id, 'RUNNING', MOCK_WF_TASKS_SUCCEEDED)
self.assertEqual(action_constants.LIVEACTION_STATUS_RUNNING, status)

@mock.patch.object(
action_service, 'is_action_canceled_or_canceling',
mock.MagicMock(return_value=True))
def test_determine_status_wf_canceled_exec_running_tasks_running(self):
wf_id = uuid.uuid4().hex
status = self.querier._determine_execution_status(wf_id, 'RUNNING', MOCK_WF_TASKS_RUNNING)
self.assertEqual(action_constants.LIVEACTION_STATUS_RUNNING, status)

@mock.patch.object(
action_service, 'is_action_canceled_or_canceling',
mock.MagicMock(return_value=False))
def test_determine_status_wf_running_exec_paused_tasks_completed(self):
wf_id = uuid.uuid4().hex
status = self.querier._determine_execution_status(wf_id, 'PAUSED', MOCK_WF_TASKS_SUCCEEDED)
self.assertEqual(action_constants.LIVEACTION_STATUS_RUNNING, status)

@mock.patch.object(
action_service, 'is_action_canceled_or_canceling',
mock.MagicMock(return_value=False))
def test_determine_status_wf_running_exec_paused_tasks_running(self):
wf_id = uuid.uuid4().hex
status = self.querier._determine_execution_status(wf_id, 'PAUSED', MOCK_WF_TASKS_RUNNING)
self.assertEqual(action_constants.LIVEACTION_STATUS_RUNNING, status)

@mock.patch.object(
executions.ExecutionManager, 'get',
mock.MagicMock(return_value=MOCK_WF_EX))
Expand Down

0 comments on commit 0925a7a

Please sign in to comment.