使用 Apache Airflow (MWAA) 的托管工作流 - 如何禁用任务 运行 对先前 运行 的依赖
Managed Workflows with Apache Airflow (MWAA) - how to disable task run dependency on previous run
我有一个 Apache Airflow 托管环境 运行ning,其中定义并启用了许多 DAG。一些 DAG 是有计划的,运行ning 在 15 分钟的计划中,而其他的则没有计划。所有 DAG 都是单任务 DAG。 DAG 的结构如下:
2 级 DAG ->(触发)1 级 DAG ->(触发)0 级 DAG
调度的DAG是level 2的DAG,level 1和level 0的DAG是非调度的。 0 级 DAG 使用 ECSOperator
调用预定义的弹性容器服务 (ECS) 任务,调用 ECS 任务中定义的 Docker 容器内的 Python ETL 脚本。 2 级 DAG 等待 1 级 DAG 完成,而 1 级 DAG 又等待 0 级 DAG 完成。 ETL 脚本生成的完整 Python 日志在 ECS 任务 运行s 的 CloudWatch 日志中可见,而 Airflow 任务日志仅显示高级日志记录。
计划的 DAG(级别 2)中的单一任务已 depends_on_past
设置为 False
,我预计结果是级别 2 DAG 的连续计划 运行s不会相互依赖,即如果一个特定的 运行 失败,它不会阻止下一个预定的 运行 发生。但是发生的事情是 Airflow 覆盖了它,我可以在 UI 中清楚地看到特定 2 级 DAG 运行 的故障正在阻止下一个 运行 被选择调度程序 - 下一个调度的 运行 状态被设置为 None
,我必须手动清除失败的 DAG 运行 状态,然后调度程序才能再次调度它。
为什么会这样?据我所知,没有 Airflow 配置选项应该覆盖 2 级 DAG 任务中 depends_on_past
的 False
任务级设置。任何指针将不胜感激。
回答“为什么会这样?”这个问题。我知道您正在观察的行为是用 wait_for_downstream = True
定义任务这一事实来解释的。 docs 声明如下:
wait_for_downstream (bool) -- when set to true, an instance of task X will wait for tasks immediately downstream of the previous instance of task X to finish successfully or be skipped before it runs. This is useful if the different instances of a task X alter the same asset, and this asset is used by tasks downstream of task X. Note that depends_on_past is forced to True wherever wait_for_downstream is used. Also note that only tasks immediately downstream of the previous task instance are waited for; the statuses of any tasks further downstream are ignored.
请记住,术语 任务 X 的先前实例指的是最后一个调度 dag_run 的 task_instance,而不是上游任务(在具有每日时间表的 DAG,即来自“昨天”的 task_instance。
这也解释了为什么一旦清除前一个 DAG 的状态就会执行您的任务 运行。
我希望它能帮助你澄清事情!
我有一个 Apache Airflow 托管环境 运行ning,其中定义并启用了许多 DAG。一些 DAG 是有计划的,运行ning 在 15 分钟的计划中,而其他的则没有计划。所有 DAG 都是单任务 DAG。 DAG 的结构如下:
2 级 DAG ->(触发)1 级 DAG ->(触发)0 级 DAG
调度的DAG是level 2的DAG,level 1和level 0的DAG是非调度的。 0 级 DAG 使用 ECSOperator
调用预定义的弹性容器服务 (ECS) 任务,调用 ECS 任务中定义的 Docker 容器内的 Python ETL 脚本。 2 级 DAG 等待 1 级 DAG 完成,而 1 级 DAG 又等待 0 级 DAG 完成。 ETL 脚本生成的完整 Python 日志在 ECS 任务 运行s 的 CloudWatch 日志中可见,而 Airflow 任务日志仅显示高级日志记录。
计划的 DAG(级别 2)中的单一任务已 depends_on_past
设置为 False
,我预计结果是级别 2 DAG 的连续计划 运行s不会相互依赖,即如果一个特定的 运行 失败,它不会阻止下一个预定的 运行 发生。但是发生的事情是 Airflow 覆盖了它,我可以在 UI 中清楚地看到特定 2 级 DAG 运行 的故障正在阻止下一个 运行 被选择调度程序 - 下一个调度的 运行 状态被设置为 None
,我必须手动清除失败的 DAG 运行 状态,然后调度程序才能再次调度它。
为什么会这样?据我所知,没有 Airflow 配置选项应该覆盖 2 级 DAG 任务中 depends_on_past
的 False
任务级设置。任何指针将不胜感激。
回答“为什么会这样?”这个问题。我知道您正在观察的行为是用 wait_for_downstream = True
定义任务这一事实来解释的。 docs 声明如下:
wait_for_downstream (bool) -- when set to true, an instance of task X will wait for tasks immediately downstream of the previous instance of task X to finish successfully or be skipped before it runs. This is useful if the different instances of a task X alter the same asset, and this asset is used by tasks downstream of task X. Note that depends_on_past is forced to True wherever wait_for_downstream is used. Also note that only tasks immediately downstream of the previous task instance are waited for; the statuses of any tasks further downstream are ignored.
请记住,术语 任务 X 的先前实例指的是最后一个调度 dag_run 的 task_instance,而不是上游任务(在具有每日时间表的 DAG,即来自“昨天”的 task_instance。
这也解释了为什么一旦清除前一个 DAG 的状态就会执行您的任务 运行。
我希望它能帮助你澄清事情!