yuseok89 commented on code in PR #75317:
URL: https://github.com/apache/airflow/pull/75317#discussion_r4578887156
##########
airflow-core/src/airflow/api_fastapi/execution_api/services/task_instances.py:
##########
@@ -67,13 +70,25 @@ def get_arg_bindings(task: SerializedOperator | None) ->
list | None:
return task.arg_bindings
-def get_execution_timeout(task: SerializedOperator | None) -> float | None:
+def get_execution_timeout(
+ task: SerializedOperator | None,
+ *,
+ start_date: datetime | None = None,
+ resuming: bool = False,
+) -> float | None:
"""
- Return the ``execution_timeout`` of *task* in seconds.
+ Return how many seconds of ``execution_timeout`` this run may still use.
Like the Python task runner, a zero timeout means no timeout, and a
negative one has
already elapsed.
+
+ When the task is resuming from deferral, the clock started at
``start_date``. Return
+ the time still left, clamped at 0, so every SDK enforces the original
limit.
"""
if task is None or not task.execution_timeout:
return None
- return max(task.execution_timeout.total_seconds(), 0.0)
+ timeout_seconds = task.execution_timeout.total_seconds()
+ if resuming and start_date is not None:
+ elapsed = (timezone.utcnow() - start_date).total_seconds()
+ timeout_seconds -= max(elapsed, 0.0)
+ return max(timeout_seconds, 0.0)
Review Comment:
Heads-up since this predates #75387: main now sends this value as it is and
documents that zero means no timeout while a negative one has already elapsed.
With the remainder clamped at 0 here, a language SDK task that resumes after
its time has run out might end up with no timeout.
--
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]