Hi Jason,

Thanks for reading the PR closely. I will let Stefan answer the first
3 questions here or on the PR.

On the last one -  yes, we will add this to the AIP.

Thanks & Regards,
Amogh Desai


On Wed, Dec 2, 2026 at 4:21 PM Amogh Desai <[email protected]> wrote:

> Hi Kaxil,
>
> Stefan and the team already use the listener and metrics in their
> deployments. I'll let him share more on that.
>
> On storing the cause - agreed. We will write it to the try's
> *state_reason* so it shows up in the UI, and I will update
> the AIP to say so. That covers most of #28116. If AIP-122 wants to count
> its budget from it instead of max_tries, we might
> likely need *failure_kind* as its own field. We can work that out during
> implementation.
>
> This also helps the self-healing retry case. For an OOM, the kind stays
> unclassified, but the reason (OOMKilled) is kept on the try,
> so the next attempt can see it.
>
> On the Celery q - yes, you are right. Today only Kubernetes and ECS report
> *infra*. When a Celery worker is lost, we cannot confidently
> tell if the node went away or the task killed it, so we do not guess. One
> way forward is the warning spot nodes get before they are reclaimed(?)
> A worker that sees it could report infra.
>
> Also responded to your comments on the AIP doc.
>
> Thanks & Regards,
> Amogh Desai
>
>
> On Wed, Dec 2, 2026 at 9:43 AM Zhe-You(Jason) Liu via dev <
> [email protected]> wrote:
>
>> Hi all,
>>
>> Thanks for writing this up. I agree that failure classification is a
>> well-scoped first step toward handling infrastructure instability in the
>> long term.
>>
>> I read the AIP page and #73816 and have a few questions.
>>
>> ## 1. Typed reason
>>
>> How about having each provider declare its `reason` tokens as a `StrEnum`?
>>
>> In #73816, `reason` is a plain `str`, so executor subclasses and listeners
>> can't see which values exist. `failure_kind` should stay a closed core
>> enum, since the metric label depends on a fixed set.
>>
>> ```python
>> class KubernetesFailureReason(StrEnum):
>>     PREEMPTION_BY_SCHEDULER = "PreemptionByScheduler"
>>     DELETION_BY_TAINT_MANAGER = "DeletionByTaintManager"
>>     DELETION_BY_POD_GC = "DeletionByPodGC"
>>     TERMINATION_BY_KUBELET = "TerminationByKubelet"
>>
>>
>> self.fail(
>>     key,
>>     failure_kind=TaskFailureKind.INFRA,
>>     reason=KubernetesFailureReason.PREEMPTION_BY_SCHEDULER,
>> )
>> ```
>>
>> A `StrEnum` is still a `str`, so the current signature and existing
>> listeners keep working. Would that also settle the open question about
>> capping the length and character set of `reason`?
>>
>> ## 2. Contract boundary
>>
>> Could the AIP add a table that shows the contract boundary? It would list
>> each public surface, such as executors, listeners, metrics, operators, Dag
>> callbacks, the UI and the REST API, and say whether it changes. That would
>> make it clear what users and provider authors need to adopt.
>>
>> Could `TaskFailureKind` also get a public import path? #73816 imports it
>> from `airflow._shared.state`.
>>
>> ## 3. Clarify where the retry policy runs and where the failure cause is
>> emitted
>>
>> It would help to state in the AIP where the AIP-105 retry policy runs and
>> where `failure_kind` and `reason` are emitted. `RetryPolicy` runs in the
>> worker while the task is still alive, and decides whether to retry based
>> on
>> the exception the task raised. `failure_kind` and `reason` only describe a
>> failure and decide nothing. `infra` in particular comes from the executor
>> in the scheduler, after the worker is gone and no `RetryPolicy` can run.
>>
>> Thanks,
>> Jason
>>
>> On Wed, Dec 2, 2026 at 11:15 AM Kaxil Naik <[email protected]> wrote:
>>
>> > On its own, AIP-97 gives a listener two new arguments and adds a metric
>> > tag, and I'm not sure who that is for.
>> > https://github.com/apache/airflow/issues/28116 has asked since 2022 for
>> > the
>> > reason to show on the task instance in the UI, and in
>> > https://github.com/apache/airflow/issues/60858 it was suggested to pass
>> > the
>> > failure type to `on_failure_callback`. Neither is in scope here.
>> > https://github.com/apache/airflow/issues/73238 wants retries by cause,
>> > which is AIP-122.
>> >
>> > Keeping retries in AIP-122 is fine maybe, but could AIP-97 store the
>> cause
>> > on the try though? There is already a per-try `state_reason` from
>> AIP-105
>> > that the UI renders, so the UI ask is mostly done and AIP-122 wouldn't
>> have
>> > to infer its budget from `max_tries`. The "Self-Healing Retries" thread
>> > from September also wants the next attempt to know why the last one died
>> > (OOM, so retry with more memory).
>> >
>> > How would this work for Celery workers on spot nodes? Going by the
>> executor
>> > table, Celery never reports `infra` (a lost worker stays unclassified),
>> so
>> > afaik this only helps KubernetesExecutor and ECS?
>> >
>> > On Tue, 1 Dec 2026 at 16:38, Ferruzzi, Dennis via dev <
>> > [email protected]> wrote:
>> >
>> > > I like that!
>> > > ________________________________
>> > > From: Amogh Desai via dev <[email protected]>
>> > > Sent: Tuesday, December 1, 2026 7:30 AM
>> > > To: [email protected] <[email protected]>
>> > > Cc: Amogh Desai <[email protected]>
>> > > Subject: [EXT] [DISCUSS] AIP-97: Task Failure Classification
>> > >
>> > > CAUTION: This email originated from outside of the organization. Do
>> not
>> > > click links or open attachments unless you can confirm the sender and
>> > know
>> > > the content is safe.
>> > >
>> > >
>> > >
>> > > AVERTISSEMENT: Ce courrier électronique provient d’un expéditeur
>> externe.
>> > > Ne cliquez sur aucun lien et n’ouvrez aucune pièce jointe si vous ne
>> > pouvez
>> > > pas confirmer l’identité de l’expéditeur et si vous n’êtes pas certain
>> > que
>> > > le contenu ne présente aucun risque.
>> > >
>> > >
>> > >
>> > > 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