Would like to ask a Airflow question , currently when we set on the DAG default args to retry 5 times if failure happens
default_args = {
'owner': 'testing',
'retries': 5,
'retry_delay': timedelta(minutes=1)
}
so what happens now is that if any tasks on the DAG fails it will retry on the tasks. Would like to know if there is any way to set if anyone of the tasks fails to restart the entire DAG instead ?
Test DAG
task1 --> task2 --> task3 --> task4
so for example if tasks 3 has occurred failure , i would like it to start from task1 again . would that be possible ??
Thank you
Theoretically, you can probably use fail_stop to fail the whole dag when the task fails. Then use on_failure_callback and invoke the dag programmatically from there. You will have to manage retries yourself there, otherwise you run the risk of rerunning infinitely.
But I would advise against doing it. One of the powers of Airflow that you can rerun the pipeline from where it failed and save on time and resources. Retries are built-in and you don’t need to implement yourself. I would encourage you to rethink of the design of your dag, and consider to redesign it in a way that you don’t have to do this. In each and every case we had in my team, we were able to do so.