Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion airflow-core/src/airflow/config_templates/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,8 @@ core:
execution_api_server_url:
description: |
The url of the execution api server. Default is ``{BASE_URL}/execution/``
where ``{BASE_URL}`` is the base url of the API Server.
where ``{BASE_URL}`` is the base url of the API Server. If ``{BASE_URL}`` is not set,
it will use ``http://localhost:8080`` as the default base url.
version_added: 3.0.0
type: string
example: ~
Expand Down
3 changes: 3 additions & 0 deletions airflow-core/src/airflow/executors/local_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ def _execute_work(log: logging.Logger, workload: workloads.ExecuteTask) -> None:
setproctitle(f"airflow worker -- LocalExecutor: {workload.ti.id}")

base_url = conf.get("api", "base_url", fallback="/")
# If it's a relative URL, use localhost:8080 as the default
if base_url.startswith("/"):
base_url = f"http://localhost:8080{base_url}"
default_execution_api_server = f"{base_url.rstrip('/')}/execution/"

# This will return the exit code of the task process, but we don't care about that, just if the
Expand Down
11 changes: 10 additions & 1 deletion airflow-core/tests/unit/executors/test_local_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,17 @@ def test_clean_stop_on_signal(self):
},
"http://custom-server/execution/",
),
({}, "http://localhost:8080/execution/"),
({("api", "base_url"): "/"}, "http://localhost:8080/execution/"),
({("api", "base_url"): "/airflow/"}, "http://localhost:8080/airflow/execution/"),
],
ids=[
"base_url_fallback",
"custom_server",
"no_base_url_no_custom",
"base_url_no_custom",
"relative_base_url",
],
ids=["base_url_fallback", "custom_server"],
)
@mock.patch("airflow.sdk.execution_time.supervisor.supervise")
def test_execution_api_server_url_config(self, mock_supervise, conf_values, expected_server):
Expand Down
1 change: 0 additions & 1 deletion dev/breeze/src/airflow_breeze/params/shell_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,6 @@ def env_variables_for_docker_commands(self) -> dict[str, str]:
_set_var(_env, "AIRFLOW__CELERY__BROKER_URL", self.airflow_celery_broker_url)
_set_var(_env, "AIRFLOW__CORE__AUTH_MANAGER", self.auth_manager_path)
_set_var(_env, "AIRFLOW__CORE__EXECUTOR", self.executor)
_set_var(_env, "AIRFLOW__CORE__EXECUTION_API_SERVER_URL", "http://localhost:8080/execution/")
if self.auth_manager == SIMPLE_AUTH_MANAGER:
_set_var(_env, "AIRFLOW__CORE__SIMPLE_AUTH_MANAGER_USERS", "admin:admin,viewer:viewer")
_set_var(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ def execute_workload(input: str) -> None:
log.info("[%s] Executing workload in Celery: %s", celery_task_id, workload)

base_url = conf.get("api", "base_url", fallback="/")
# If it's a relative URL, use localhost:8080 as the default
if base_url.startswith("/"):
base_url = f"http://localhost:8080{base_url}"
default_execution_api_server = f"{base_url.rstrip('/')}/execution/"

supervise(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,9 @@ def _run_job_via_supervisor(

try:
base_url = conf.get("api", "base_url", fallback="/")
# If it's a relative URL, use localhost:8080 as the default
if base_url.startswith("/"):
base_url = f"http://localhost:8080{base_url}"
default_execution_api_server = f"{base_url.rstrip('/')}/execution/"

supervise(
Expand Down
Loading