You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "dirrao (via GitHub)" <gi...@apache.org> on 2024/02/01 09:18:33 UTC
Re: [PR] Adding ability to automatically set DAG to off after X times it failed sequentially [airflow]
dirrao commented on code in PR #36935:
URL: https://github.com/apache/airflow/pull/36935#discussion_r1474086299
##########
airflow/models/dagrun.py:
##########
@@ -498,6 +498,37 @@ def fetch_task_instances(
tis = tis.where(TI.task_id.in_(task_ids))
return session.scalars(tis).all()
+ @internal_api_call
+ def _check_last_N_dagruns_failed(
+ self,
+ dag_id: str,
+ number_of_dag_runs: int,
+ session: Session
+ ):
+ """Check if last N dags failed."""
+ dag_runs = session.query(DagRun).filter(DagRun.dag_id == dag_id) \
+ .order_by(DagRun.execution_date.desc()) \
+ .limit(number_of_dag_runs).all()
+
+ """ Marking dag as paused, if needed"""
+ toBePaused = all(dag_run.state == DagRunState.FAILED for dag_run in dag_runs)
Review Comment:
I am referring to the limit query might give less records. So we need cross check the failed count.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org