Skip to content

5. Always Clean Up, Never Hide a Failure

Difficulty: Hard · Topic: Trigger rules

The DAG nightly_spark_job runs @daily from 2026-01-01 (no catchup). It rents a cluster for one job:

All four are BashOperator tasks with no retries. You may add other tasks if you need them.

Your DAG file is run in a simulation of the Airflow 3 scheduler against 5 scenarios, including hidden ones.

Sample scenario: The job fails

Deployed 2026-01-10 01:00 UTC, read at 2026-01-10 03:00 UTC.

Expected runs

Hints

Hint 1trigger_rule="all_done" runs a task once every upstream task has finished, whatever their states.
Hint 2trigger_rule="one_failed" runs a task as soon as one upstream task has failed, without waiting for the rest; if they all finish without a failure, it is skipped.
Hint 3Airflow sets a run's state from its leaf tasks (the ones with nothing downstream). If delete_cluster and notify_failure both succeed, the run succeeds even though the job failed. Airflow's docs fix this with a "watcher": one more task that fails when an upstream task failed.

Learn the concepts

More Airflow problems

All Airflow problems · Learn Airflow