paultmathew commented on code in PR #67229:
URL: https://github.com/apache/airflow/pull/67229#discussion_r3277835523
##########
providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/triggers/pod.py:
##########
@@ -306,6 +313,27 @@ async def _wait_for_container_completion(self) ->
TriggerEvent:
if self.logging_interval is not None:
time_get_more_logs = time_begin +
datetime.timedelta(seconds=self.logging_interval)
while True:
+ # ``execution_deadline`` is the operator's translation of the
+ # task-level ``execution_timeout`` into an absolute UTC timestamp
+ if self.execution_deadline is not None and time.time() >=
self.execution_deadline:
+ self.log.info(
Review Comment:
1. **Early check at the top of `run()`** — short-circuits with a
`status="timeout"` event when the deadline has already elapsed before the
trigger picks the task up (e.g. long-paused triggerer queue, or re-defer after
deadline passed).
2. **`_wait_for_pod_start_within_deadline` wrapper** — calls the existing
`_wait_for_pod_start()` inside `asyncio.wait_for(...,
timeout=remaining_seconds)` when an `execution_deadline` is set. On
`asyncio.TimeoutError` we raise `PodLaunchTimeoutException`, which the existing
`except` clause in `run()` (line ~227) already converts to a `status="timeout"`
TriggerEvent — so the operator's terminal-event path handles startup-phase
timeouts identically to mid-poll timeouts.
Added regression test
`test_run_emits_timeout_when_deadline_passed_during_pod_startup` that mocks
`_wait_for_pod_start` to hang forever and asserts the deadline-induced timeout
fires within ~1s with `status="timeout"`.
We still don't bound `pod_manager.await_pod_start` itself with the deadline
— wrapping the whole `_wait_for_pod_start()` coroutine in `asyncio.wait_for` is
sufficient because the cancellation propagates inward. The `events_task =
asyncio.create_task(self.pod_manager.watch_pod_events(...))` cleanup in the
`finally` block runs as expected when `wait_for` cancels the parent task.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]