Reputation: 156
Our airflow is forced to interact with a company with a very poor system. Its not unusual for our DAG to get stuck waiting for a report that never actually gets completed. This DAG runs daily pulling the the same information, so if its time for the next run it would be nice to just kill the last run and move on with the new one. I haven't found anything saying Airflow has a DAG argument that can achieve this. Is there a quick easy setting for this behavior, or would it need to be done logically in the sensor that checks if the report is complete?
Upvotes: 1
Views: 1088
Reputation: 2516
If your DAG is scheduled daily, how about setting dagrun_timeout
to 24 hours? I believe this should in effect kill the previous dag run around when it kicks off a new one. Related question about setting DAG timeouts.
Alternatively, you could either use a PythonOperator
, define your own operator, or extend the report sensor you describe to kill the previous DagRun
programmatically. I believe that this would look like...
dag_run.get_previous_dagrun()
prev_dag_run.set_state
My recommendation would be to set the timeout given these two options. I agree that there is no specific kill_previous_run
dag argument
Upvotes: 1