Hi Sameer,
+1 on the direction, and +1 on Jarek's points, in particular deciding
the common.compat route now and showing a few real migrations. I won't
repeat those; here is what I would add.
1. Timeout taking precedence over a terminal state. The loop checks the
deadline after a poll has returned and before it looks at the state.
If the poll comes back with a success a few milliseconds after
end_time, the task fails although the remote job is done, and a task
retry then reruns a job that already succeeded. Existing triggers
behave the other way round: Databricks only checks before it starts a
poll [1], so a result in hand is used. What is the reason for the
stricter rule? I would propose to check before a poll and after an
error, and never between a successful poll and its state.
2. The deadline, beyond the naive/aware fix Jarek mentioned. The
existing triggers pass a float epoch compared with time.time()
[1][2], so a datetime changes the serialized arguments of triggers
that are in flight during an upgrade; the migration section should
say how that is handled. Also, the OpenAI batch trigger deprecated
end_time in favour of a timeout measured with time.monotonic(),
because wall-clock deadlines move with NTP corrections and VM pauses
[3]. The AIP makes the opposite choice for a good reason (queueing
and triggerer restarts should count), but it would help to name that
trade-off and that precedent.
3. Who cancels the remote job on a timeout. on_kill() does not fire on a
trigger timeout [4], so after the timeout event the remote job keeps
running unless the operator cancels it when it resumes. One sentence
saying that the operator's completion method owns that cancel would
close the gap, and it is the real advantage of end_time over
defer(timeout=...).
4. Retry layers. On top of what Jarek wrote about the retry design: many
async hooks and SDKs already retry internally, so retries multiply
(hook, trigger, task). The AIP says it does not override the hooks'
behaviour; a recommendation for one layer would help authors.
5. On the scope question (Jarek's point 6), a concrete example: the IBM
MQ AwaitMessageTrigger [5]. It waits for the next message without a
deadline, and its hook retries with exponential back-off from 1 s to
60 s without a budget [6], so it cannot use PollingTrigger. I think
out of scope is the right answer for such triggers, but they need the
same error classification and back-off. Could retry and back-off be a
piece of their own that PollingTrigger uses, so that a later base
class for message-wait triggers can reuse it with an unbounded
budget?
6. On the number of hooks, an alternative to consider next to default
event builders: the text describes the provider part as "return
either continue or the appropriate TriggerEvent", which is a single
method:
async def poll(self) -> TriggerEvent | None
The framework never needs the state itself, only "done or not".
One small one: the logging and metrics promised in the Motivation are
not specified yet (names, tags).
Regards,
David
[1]
https://github.com/apache/airflow/blob/main/providers/databricks/src/airflow/providers/databricks/triggers/databricks.py
[2]
https://github.com/apache/airflow/blob/main/providers/airbyte/src/airflow/providers/airbyte/triggers/airbyte.py
[3]
https://github.com/apache/airflow/blob/main/providers/openai/src/airflow/providers/openai/triggers/openai.py
[4]
https://github.com/apache/airflow/blob/main/airflow-core/src/airflow/triggers/base.py
(docstring of BaseTrigger.on_kill)
[5]
https://github.com/apache/airflow/blob/main/providers/ibm/mq/src/airflow/providers/ibm/mq/triggers/mq.py
[6]
https://github.com/apache/airflow/blob/main/providers/ibm/mq/src/airflow/providers/ibm/mq/hooks/mq.py
(aconsume)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]