How to mark an Airflow DAG run as failed if any task fails?

后端 未结 2 1482
梦毁少年i
梦毁少年i 2021-02-19 15:48

Is it possible to make an Airflow DAG fail if any task fails?

I usually have some cleaning up tasks at the end of a DAG and as it is now, whenever the last task succeeds

2条回答
  •  我寻月下人不归
    2021-02-19 16:32

    Facing a similar problem. It is not a bug but it could be a nice feature to add this property to Dag.

    As a workaround, I you can push a XCOM variable during the task that is allowed to fail and in the downstream tasks do something like

    if ti.xcom_pull(key='state', task_ids=task_allowed_to_fail_id) == 'FAILED': raise ValueError('Force failure because upstream task has failed')

提交回复
热议问题