Hi Sameer, Thanks for putting this together. The problem is real: a lot of provider triggers hand-roll the same polling loop, and the edge cases (timeout vs. terminal state, retry budget reset, swallowing CancelledError) get decided differently in every review. Writing down the precedence rules explicitly is valuable on its own.
On your question whether it needs an AIP: yes, I think it does. It adds a new public Core API that providers will build on, and you want it to become the recommended standard for new polling triggers. That is exactly the kind of change an AIP and a vote are for, rather than PRs plus lazy consensus. A few concerns I'd like the AIP to address: 1. Provider adoption vs. Core release. Providers support Airflow versions way back (currently 2.11), so a class that only ships in a new Core release would be unusable by most providers for a long time. I propose to decide this now rather than leave it open: add PollingTrigger to Core, and expose it via apache-airflow-providers-common-compat, which imports the Core class when available and falls back to a copy of the implementation for older Airflow versions. Providers then import it from common.compat and can adopt it immediately by bumping their minimum common-compat version. That is the pattern we already use for other new Core/SDK APIs. 2. Prior art. The Amazon provider already has a very similar abstraction: AwsBaseWaiterTrigger (providers/amazon/.../aws/triggers/base.py), with ~24 subclasses, shared waiter_delay / waiter_max_attempts handling and serialization. The AIP should discuss it: would Amazon triggers migrate, or would we end up with two parallel abstractions? It also has useful lessons, e.g. rejecting an incomplete subclass at import time via __init_subclass__. 3. The most valuable parts are still "to be defined": backoff policy, retry configuration and the max_retries default. Without them the class is mostly a loop with checkpoints. Please also state whether the retry attempt count is serialized - if not, a triggerer restart silently resets the retry budget (which may be fine, but should be explicit). In the appendix, _retry_budget_exhausted() is referenced but not defined, max_retries is missing from the constructor, and there is no serialize() at all - so the retry design, and what survives a triggerer restart, still has to be written down. 4. Event payloads. Seven hooks is a lot for a "simple" polling trigger, and each subclass still builds its own success / error / timeout events. Default event builders with a standard payload (status / message, possibly reusing the existing TriggerFailureReason in the Task SDK) would remove a real source of inconsistency in the execute_complete methods, and leave most subclasses implementing only poll(), get_state() and terminal_states. 5. Small correctness points in the appendix: end_time is described as timezone-aware but compared with naive datetime.now() - with stdlib datetime that raises TypeError, so it should use timezone.utcnow(). And the timeout can overshoot by up to one poll_interval; sleeping min(poll_interval, remaining) fixes that cheaply. 6. Scope vs. BaseEventTrigger. Polling triggers used for event-driven scheduling (SQS-style) never reach a terminal state. Please state explicitly whether they are in or out of scope. 7. Before making it the "recommended standard", I'd like to see 2-3 real migrations from different providers in the AIP, showing how much code is removed and that the emitted events stay unchanged. That would make the case much stronger than the abstraction alone. Looking forward to the next iteration. J. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
