Skip to content

Commit

Permalink
Properly build URL to retrieve logs independently from system (#26337)
Browse files Browse the repository at this point in the history
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.

(cherry picked from commit 1838602)
  • Loading branch information
potiuk committed Sep 11, 2022
1 parent ea22657 commit 6f24836
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions airflow/utils/log/file_task_handler.py
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 6f24836

Please sign in to comment.