From 18386026c28939fa6d91d198c5489c295a05dcd2 Mon Sep 17 00:00:00 2001 From: Jarek Potiuk Date: Sun, 11 Sep 2022 19:05:06 +0200 Subject: [PATCH] Properly build URL to retrieve logs independently from system (#26337) The previous way of building the path depended on the OS path but it was really used to build the URL so we should use urllib instead of os.path.join. --- airflow/utils/log/file_task_handler.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/airflow/utils/log/file_task_handler.py b/airflow/utils/log/file_task_handler.py index d2beb54c5ffd..0435912476a2 100644 --- a/airflow/utils/log/file_task_handler.py +++ b/airflow/utils/log/file_task_handler.py @@ -21,6 +21,7 @@ import warnings from pathlib import Path from typing import TYPE_CHECKING, Optional +from urllib.parse import urljoin from airflow.configuration import AirflowConfigException, conf from airflow.exceptions import RemovedInAirflow3Warning @@ -194,8 +195,8 @@ def _read(self, ti, try_number, metadata=None): else: import httpx - url = os.path.join("http://{ti.hostname}:{worker_log_server_port}/log", log_relative_path).format( - ti=ti, worker_log_server_port=conf.get('logging', 'WORKER_LOG_SERVER_PORT') + url = urljoin( + f"http://{ti.hostname}:{conf.get('logging', 'WORKER_LOG_SERVER_PORT')}/log", log_relative_path ) log += f"*** Log file does not exist: {location}\n" log += f"*** Fetching from: {url}\n"