You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "FrankYang0529 (via GitHub)" <gi...@apache.org> on 2026/10/15 08:19:58 UTC
[PR] Fix Edge workers not reporting the final state of deadline callbacks [airflow]
FrankYang0529 opened a new pull request, #74784:
URL: https://github.com/apache/airflow/pull/74784
### Why
- On Airflow 3.3+ and edge3 3.8.0+ run executor callbacks, such as the `SyncCallback` of a Deadline Alert, on Edge workers. With the default `[edge] push_logs = True` the worker never reports whether the callback succeeded or failed.
- The worker pushes the callback's log with the job key that the Edge executor builds for callbacks. That key has `dag_id="ExecuteCallback"`. The log route on the API server looks up a task instance for that key. No such task instance exists, so the route fails with HTTP 500. Even a callback whose code logs nothing leaves a non-empty log file, so the push fails for every callback.
### How
- API server: for a callback job, the log route reads `log_path` from the workload JSON that the scheduler stored in the `command` column of the `edge_job` row. The worker reads the callback log from that same relative path. For a callback whose row or `log_path` is missing, both log routes return 404 instead of 500.
- Worker: pushing logs is now best effort. The worker logs an error from a push and still reports the final state. If pushes keep failing with 5xx, each push still waits for the client's retries, so the state can arrive a few minutes late. The worker change also handles an older API server that does not have the log route change above.
<!-- SPDX-License-Identifier: Apache-2.0
https://www.apache.org/licenses/LICENSE-2.0 -->
<!--
Thank you for contributing!
Please provide above a brief description of the changes made in this pull request.
Write a good git commit message following this guide: https://chris.beams.io/posts/git-commit/
Please make sure that your code changes are covered with tests.
And in case of new features or big changes remember to adjust the documentation.
For user-facing UI changes, please attach before/after screenshots (or a short
screen recording) so reviewers can assess the visual impact.
Feel free to ping (in general) for the review if you do not see reaction for a few days
(72 Hours is the minimum reaction time you can expect from volunteers) - we sometimes miss notifications.
In case of an existing issue, reference it using one of the following:
* closes: #ISSUE
* related: #ISSUE
-->
---
##### Was generative AI tooling used to co-author this PR?
<!--
If generative AI tooling has been used in the process of authoring this PR, please
change below checkbox to `[X]` followed by the name of the tool, uncomment the "Generated-by".
-->
- [X] Yes - Claude Code
<!--
Generated-by: [Tool Name] following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
-->
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix Edge workers not reporting the final state of deadline callbacks [airflow]
Posted by "Lee-W (via GitHub)" <gi...@apache.org>.
Lee-W commented on code in PR #74784:
URL: https://github.com/apache/airflow/pull/74784#discussion_r4344295982
##########
providers/edge3/src/airflow/providers/edge3/worker_api/routes/logs.py:
##########
@@ -32,18 +33,24 @@
from airflow.providers.common.compat.sdk import TaskInstanceKey, conf
from airflow.providers.edge3.models.edge_job import EdgeJobModel
from airflow.providers.edge3.models.edge_logs import EdgeLogsModel
+from airflow.providers.edge3.models.types import is_callback_job
from airflow.providers.edge3.worker_api.auth import jwt_token_authorization_rest
from airflow.providers.edge3.worker_api.datamodels import PushLogsBody, WorkerApiDocs
from airflow.utils.log.file_task_handler import FileTaskHandler
from airflow.utils.session import NEW_SESSION, provide_session
+if TYPE_CHECKING:
+ from sqlalchemy.orm import Session
+
logs_router = AirflowRouter(tags=["Logs"], prefix="/logs")
@cache
@provide_session
def _logfile_path(task: TaskInstanceKey, task_instance_id: UUID | None = None, *, session=NEW_SESSION) -> str:
"""Elaborate the (relative) path and filename to expect from task execution."""
+ if is_callback_job(task.dag_id, task.task_id, task.run_id, task.try_number, task.map_index):
+ return _callback_logfile_path(task, session=session)
Review Comment:
```suggestion
return _get_callback_logfile_path(task, session=session)
```
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix Edge workers not reporting the final state of deadline callbacks [airflow]
Posted by "Lee-W (via GitHub)" <gi...@apache.org>.
Lee-W commented on code in PR #74784:
URL: https://github.com/apache/airflow/pull/74784#discussion_r4344271048
##########
providers/edge3/src/airflow/providers/edge3/worker_api/routes/logs.py:
##########
@@ -74,13 +81,39 @@ def _logfile_path(task: TaskInstanceKey, task_instance_id: UUID | None = None, *
return FileTaskHandler(".")._render_filename(ti, task.try_number)
+def _callback_logfile_path(task: TaskInstanceKey, *, session: Session) -> str:
Review Comment:
```suggestion
def _get_callback_logfile_path(task: TaskInstanceKey, *, session: Session) -> str:
```
##########
providers/edge3/src/airflow/providers/edge3/worker_api/routes/logs.py:
##########
@@ -74,13 +81,39 @@ def _logfile_path(task: TaskInstanceKey, task_instance_id: UUID | None = None, *
return FileTaskHandler(".")._render_filename(ti, task.try_number)
+def _callback_logfile_path(task: TaskInstanceKey, *, session: Session) -> str:
+ """
+ Return a callback's ``log_path`` from the workload JSON in the callback's ``edge_job`` row.
+
+ Executor callbacks have no task instance row, so their log path cannot be rendered from a task
+ instance. When queuing this callback, the scheduler stored the workload JSON in the ``command``
+ column of the callback's ``edge_job`` row. The ``log_path`` in that JSON is a path relative to the
+ log folder, and the callback supervisor process writes the callback log at that path on the Edge
+ worker. Raise HTTP 404 if the ``edge_job`` row is missing or the JSON has no ``log_path``.
+ """
+ command = session.scalar(
+ select(EdgeJobModel.command).where(
+ EdgeJobModel.dag_id == task.dag_id,
+ EdgeJobModel.task_id == task.task_id,
+ EdgeJobModel.run_id == task.run_id,
+ EdgeJobModel.map_index == task.map_index,
+ EdgeJobModel.try_number == task.try_number,
+ )
+ )
+ log_path = json.loads(command).get("log_path") if command else None
+ if not log_path:
+ raise HTTPException(status.HTTP_404_NOT_FOUND, f"No log path found for callback {task.task_id}")
+ return log_path
+
Review Comment:
```suggestion
if command and (log_path := json.loads(command).get("log_path")):
return log_path
raise HTTPException(status.HTTP_404_NOT_FOUND, f"No log path found for callback {task.task_id}")
```
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix Edge workers not reporting the final state of deadline callbacks [airflow]
Posted by "Lee-W (via GitHub)" <gi...@apache.org>.
Lee-W commented on code in PR #74784:
URL: https://github.com/apache/airflow/pull/74784#discussion_r4344293999
##########
providers/edge3/src/airflow/providers/edge3/worker_api/routes/logs.py:
##########
@@ -74,13 +81,41 @@ def _logfile_path(task: TaskInstanceKey, task_instance_id: UUID | None = None, *
return FileTaskHandler(".")._render_filename(ti, task.try_number)
+def _callback_logfile_path(task: TaskInstanceKey, *, session: Session) -> str:
+ """
+ Return a callback's ``log_path`` from the workload JSON in the callback's ``edge_job`` row.
+
+ Executor callbacks have no task instance row, so their log path cannot be rendered from a task
+ instance. When queuing this callback, the scheduler stored the workload JSON in the ``command``
+ column of the callback's ``edge_job`` row. The ``log_path`` in that JSON is a path relative to the
+ log folder, and the callback supervisor process writes the callback log at that path on the Edge
+ worker. Raise HTTP 404 if the ``edge_job`` row is missing or the JSON has no ``log_path``.
+ """
+ command = session.scalar(
+ select(EdgeJobModel.command).where(
+ EdgeJobModel.dag_id == task.dag_id,
+ EdgeJobModel.task_id == task.task_id,
+ EdgeJobModel.run_id == task.run_id,
+ EdgeJobModel.map_index == task.map_index,
+ EdgeJobModel.try_number == task.try_number,
+ )
+ )
+ log_path = json.loads(command).get("log_path") if command else None
+ if not log_path:
+ raise HTTPException(status.HTTP_404_NOT_FOUND, f"No log path found for callback {task.task_id}")
+ return log_path
Review Comment:
```suggestion
```
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix Edge workers not reporting the final state of deadline callbacks [airflow]
Posted by "Lee-W (via GitHub)" <gi...@apache.org>.
Lee-W merged PR #74784:
URL: https://github.com/apache/airflow/pull/74784
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org