oboki commented on code in PR #50175:
URL: https://github.com/apache/airflow/pull/50175#discussion_r2075139859
##########
airflow-core/src/airflow/utils/log/file_task_handler.py:
##########
@@ -474,6 +480,20 @@ def _get_log_retrieval_url(
hostname = ti.triggerer_job.hostname
log_relative_path = self.add_triggerer_suffix(log_relative_path,
job_id=ti.triggerer_job.id)
else:
+ from airflow.models.taskinstancehistory import TaskInstanceHistory
+
+ ti = (
+ session.query(TaskInstanceHistory)
+ .filter(
+ TaskInstanceHistory.dag_id == ti.dag_id,
+ TaskInstanceHistory.task_id == ti.task_id,
+ TaskInstanceHistory.run_id == ti.run_id,
+ TaskInstanceHistory.map_index == ti.map_index,
+ TaskInstanceHistory.try_number == try_number,
+ )
+ .one_or_none()
+ or ti
+ )
Review Comment:
@jason810496
Thanks for the review!
I tried to follow your suggestion by making changes to the `get_log`
endpoint, but I ran into a few issues.
https://github.com/apache/airflow/blob/31c7c9626bab3e39a5a0592b87e220007d94d6b9/airflow-core/src/airflow/api_fastapi/core_api/routes/public/log.py#L105-L125
First, it seems that the `try_number` parameter isn't actually used in this
context.
The `if ti is None:` condition doesn't behave as expected, so `ti` is always
a `TaskInstance`, not a `TaskInstanceHistory`.
https://github.com/apache/airflow/blob/31c7c9626bab3e39a5a0592b87e220007d94d6b9/airflow-core/src/airflow/api_fastapi/core_api/routes/public/log.py#L118
I tried updating the logic to fetch `TaskInstanceHistory` when appropriate,
but ran into type issues, as many of the subsequent calls expect a
`TaskInstance` rather than a `TaskInstanceHistory`.
And even if this is resolved at the API level, the request still goes
through the `log_reader`, which in the end relies on the `file_task_handler`.
--
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]