ephraimbuddy commented on code in PR #47557:
URL: https://github.com/apache/airflow/pull/47557#discussion_r2015982948
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/dags.py:
##########
@@ -246,6 +248,29 @@ def patch_dag(
data = patch_body.model_dump(include=fields_to_update, by_alias=True)
+ is_paused = data.get("is_paused")
+
+ active_dag_runs = session.scalars(
+ select(DagRun).filter(
+ DagRun.dag_id == dag_id, DagRun.state.in_([DagRunState.RUNNING,
DagRunState.QUEUED])
+ )
+ ).all()
+
+ for dag_run in active_dag_runs:
+ if is_paused:
+ dag_run.set_state(DagRunState.FAILED)
+ running_task_instances = session.scalars(
+ select(TaskInstance).filter(
+ TaskInstance.dag_id == dag_run.dag_id,
+ TaskInstance.run_id == dag_run.run_id,
+ TaskInstance.state == TaskInstanceState.RUNNING,
+ )
+ ).all()
+ for task_instance in running_task_instances:
+ task_instance.set_state(TaskInstanceState.FAILED)
Review Comment:
As @pierrejeambrun suggested, we should discuss this change in behaviour in
dev list.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]