ferruzzi commented on code in PR #66610:
URL: https://github.com/apache/airflow/pull/66610#discussion_r3236434672
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/ui/deadlines.py:
##########
@@ -201,3 +205,59 @@ def get_dag_deadline_alerts(
alerts = session.scalars(alerts_select)
return DeadlineAlertCollectionResponse(deadline_alerts=alerts,
total_entries=total_entries)
+
+
+@deadlines_router.get(
+ "/dagRuns/{dag_run_id}/callbacks/{callback_id}/logs",
+ responses=create_openapi_http_exception_doc(
+ [
+ status.HTTP_404_NOT_FOUND,
+ ]
+ ),
+ dependencies=[
+ Depends(
+ requires_access_dag(
+ method="GET",
+ access_entity=DagAccessEntity.TASK_LOGS,
+ )
+ ),
+ ],
+ response_model=TaskInstancesLogResponse,
+ response_model_exclude_unset=True,
+)
+def get_callback_logs(
+ dag_id: str,
+ dag_run_id: str,
+ callback_id: UUID,
+ session: SessionDep,
+) -> TaskInstancesLogResponse:
+ """
+ Get execution logs for a callback associated with a deadline.
+
+ Returns the logs produced during callback execution. These logs are
uploaded
+ to remote storage (or written locally) by the callback supervisor after
execution.
+ """
+ # Verify the callback exists
+ callback = session.scalar(select(Callback).where(Callback.id ==
callback_id))
+ if callback is None:
+ raise HTTPException(
+ status.HTTP_404_NOT_FOUND,
+ f"Callback with id `{callback_id}` was not found",
+ )
+
+ # Verify the dag_run exists with matching dag_id
+ dag_run = session.scalar(select(DagRun).where(DagRun.dag_id == dag_id,
DagRun.run_id == dag_run_id))
+ if dag_run is None:
+ raise HTTPException(
+ status.HTTP_404_NOT_FOUND,
+ f"DagRun with dag_id: `{dag_id}` and run_id: `{dag_run_id}` was
not found",
+ )
+
Review Comment:
I know this is a WIP, but a small point. You check if the callback
exists, and you check if the dagrun exists, but maybe you should verify that
the callback is tied to that specific run instead of trusting the input? Or
maybe that's overthinking it.
--
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]