ephraimbuddy commented on code in PR #76303:
URL: https://github.com/apache/airflow/pull/76303#discussion_r4709786883
##########
airflow-core/src/airflow/models/trigger.py:
##########
@@ -931,19 +932,24 @@ def _submit_callback_if_necessary() -> None:
TaskInstanceState.FAILED,
TaskInstanceState.UP_FOR_RETRY,
):
- if task_instance.dag_model.relative_fileloc is None:
+ callback_filepath = (
+ dag.relative_fileloc if dag is not None else None
+ ) or task_instance.dag_model.relative_fileloc
+ if callback_filepath is None:
raise RuntimeError("relative_fileloc should not be None for a
finished task")
from airflow.models.dag_version import
_resolve_ti_callback_bundle_info
bundle_name, bundle_version, version_data =
_resolve_ti_callback_bundle_info(task_instance)
request = TaskCallbackRequest(
- filepath=task_instance.dag_model.relative_fileloc,
+ filepath=callback_filepath,
ti=task_instance_to_runtime(
task_instance,
model=TIDataModel,
map_index=TaskCoordinateResolver(dag_bag,
session).public_map_index(task_instance),
),
task_callback_type=callback_type,
+ # Only a worker running the task sets it, and ``defer_task``
clears it.
+ task_started=task_instance.last_heartbeat_at is not None,
Review Comment:
A task can enter `DEFERRED` directly or after running on a worker. By the
time the triggerer handles it, both have the same state. The recorded PID
distinguishes the two. It survives rescheduling and is cleared for a new try,
so the callback inherits the task’s queue only if that try ran on a worker.
##########
airflow-core/src/airflow/models/callback.py:
##########
@@ -321,26 +427,55 @@ class ExecutorCallback(Callback):
__mapper_args__ = {"polymorphic_identity": CallbackType.EXECUTOR}
def __init__(
- self, callback_def: ImportPathExecutorCallbackDefProtocol,
fetch_method: CallbackFetchMethod, **kwargs
+ self,
+ callback_def: ImportPathExecutorCallbackDefProtocol | None,
+ fetch_method: CallbackFetchMethod,
+ *,
+ request: CallbackRequest | None = None,
+ **kwargs,
):
"""
- Initialize an ExecutorCallback from a callback definition and fetch
method.
+ Initialize an ExecutorCallback from a callback definition, or from a
Dag processor callback request.
- :param callback_def: Callback definition with path, kwargs, and
executor
+ :param callback_def: Callback definition with path, kwargs, and
executor; ``None`` with ``request``
:param fetch_method: Method to fetch the callback at runtime
+ :param request: Dag processor callback request, for a callback the
scheduler routes to an executor
:param kwargs: Passed to parent Callback.__init__ (see base class for
details)
"""
from airflow.serialization.encoders import
encode_stored_callback_kwargs
super().__init__(**kwargs)
self.fetch_method = fetch_method
+ if request is not None:
+ self.bundle_name = request.bundle_name
+ self.data |= _get_request_data(request)
+ return
Review Comment:
I kept one ORM type because both forms use the same queue and claim logic.
The part that differs is serialization, so each definition now provides its own
`serialize()`, and `from_dag_processor_request()` selects `DAG_ATTRIBUTE`.
##########
providers/amazon/src/airflow/providers/amazon/aws/executors/aws_lambda/lambda_executor.py:
##########
@@ -73,6 +74,10 @@
WorkloadKey: TypeAlias = TaskInstanceKey # type: ignore[no-redef,
misc]
+# Allow for Lambda's asynchronous retries before SQS's maximum 14-day message
retention.
+_RELEASED_CALLBACK_RETENTION = 15 * 24 * 60 * 60
Review Comment:
An idle Lambda executor now stops polling SQS and the DLQ 6 hours 15 minutes
after the last release. The 15-day value only controls how long it remembers a
key, so it can acknowledge a late receipt if it’s already polling for other
work.
--
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]