Hi all,

I, on behalf of AIP-97 authors  would like to start a discussion on AIP-97:
https://cwiki.apache.org/confluence/spaces/AIRFLOW/pages/399279312/AIP-97+Task+Failure+Classification

*The problem*
Today, when a task fails, Airflow records that it failed, not why. A Spot
preemption and a bug in the task can trigger the same alert. The platform
team can get
paged for a bug in a Dag, or the Dag author can end up chasing a node
failure.

The executor often knows the cause of failure, even after the worker is
gone. For example, Kubernetes marks a preempted pod with `DisruptionTarget`
and
KubernetesExecutor already knows that.

*The proposal*
- Failure listeners and logs can include two optional fields: failure_kind
(identified in the AIP as infra, application, timeout, manual) and reason.
Metrics use only the failure category as a tag.
- infra is set by executors only when the backend can confidently identify
the cause. Anything unclear stays unclassified.
- Retries, clears, and callbacks do not change. This AIP only labels
failures.
The AIP page has a POC and end-to-end examples.

*How this differs from retry policies*
A retry policy runs in the worker and decides what to do with an exception
the task raised. If the worker itself is gone, for example, a preempted
pod, there is
no room to capture the exception and no policy runs.

AIP-97 covers that case. It doesn't decide anything - it only records why
the task stopped.

*Why now*
We have been working on Airflow’s *durable execution* story and have made
certain advancements in that domain -
- Airflow 3.3: When a worker crashes mid-job, the retry reconnects to the
job that's still running, instead of submitting a duplicate.
- Airflow 3.5: When the external job itself fails, the retry resumes it
from where it stopped, for example by repairing a Databricks run so only
the failed Databricks
tasks run again.


Both of these act on a task after it stops, but neither knows why it
stopped. Was it a preempted node, a bug in the task, a timeout, or someone
marking it failed?
AIP-97 adds that missing piece, so Airflow and the people running it can
treat each case for what it is.

I'd welcome feedback here or on the AIP.

P.S.: An incarnation / private implementation of this was also presented at
the Community Over Code in Glasgow this year, and it was well received:
https://www.youtube.com/watch?v=RJ2AtvJbEO4

Thanks & Regards,
Amogh Desai

Reply via email to