[Fix] Deckhand Create Site Action Tag

The workflow should fail if 'armada_build', 'skip_upgrade_airflow'
or 'upgrade_airflow' tasks are in 'upstream_failed' state. This
can happen if any of the upstream tasks are in failed state. For
instance, if there is a failure in the preflight checks for the
UCP components, all its associated downstream tasks will stop and
its downstream tasks such as 'armada_build' will go into 'upstream_failed'
state.

As it is right now, the deckhand_create_site_action_tag Operator
will treat the above mentioned scenario as successful (since task is
in 'upstream_failed' and not 'failed' state) and will proceed to create
the 'site-action-success' tag instead of 'site-action-failure' tag.

Hence we will need to capture both task states as failed state. This patch
set is meant to fix this erroneous behavior.

Change-Id: I01066656d4cc9169d85c6a535d8241470761666a
This commit is contained in:
Anthony Lin 2018-05-08 07:34:25 +00:00
parent 8a544cdd7f
commit 767ea681bb

View File

@ -22,6 +22,7 @@ from airflow.exceptions import AirflowException
from deckhand_base_operator import DeckhandBaseOperator
FAILED_STATUSES = ('failed', 'upstream_failed')
LOG = logging.getLogger(__name__)
@ -128,10 +129,11 @@ class DeckhandCreateSiteActionTagOperator(DeckhandBaseOperator):
task_result[i] = self.check_task_result(i)
# Check for failed task(s)
failed_task = [x for x in task if task_result[x] == 'failed']
failed_task = [x for x in task if task_result[x] in FAILED_STATUSES]
if failed_task:
LOG.info("Task(s) in the workflow has/have failed: %s",
LOG.info("Either upstream tasks or tasks in the "
"workflow have failed: %s",
", ".join(failed_task))
return False