A task's trigger rule decides when it may run, from the states of its upstream tasks. The default, all_success, waits for every upstream task to succeed; a failure upstream makes it upstream_failed, and a skip makes it skipped.
The other rules you will meet: all_done (run once everything upstream finished, whatever the outcome: cleanups), one_failed (run as soon as one upstream task fails: alerts), one_success, all_failed, none_failed (no upstream failed; skips are fine), none_failed_min_one_success (the join after a branch) and always.
@task(trigger_rule="all_done")
def cleanup(): ...
Careful with all_done at the end of a Dag: Airflow decides a run's state from its last tasks, so a cleanup that succeeds after a failed load can turn the whole run green. Setup and teardown tasks, later in this unit, avoid that.
A cleanup that always runs, and an alert that runs only when something upstream failed.