Skip to content

LocalExecutor url resolution makes bad decisions regarding defaults #53033

@kcphila

Description

@kcphila

Apache Airflow version

3.0.2

If "Other Airflow 2 version" selected, which one?

No response

What happened?

I'm testing a migration from Airflow 2.10.2 to 3.0.2 in a custom Dockerized environment using LocalExecutor. In this process, I generated a barebones airflow.cfg for 3.0.2 and added in customizations from there.

The scheduler was crashing on every execution, and after logging into the container and hacking around in code, I have identified why. I ended up setting an empty base_url, e.g. this line in the airflow.cfg:

[api]
base_url =

The following code is in local_executor.py:

from airflow.configuration import conf
...
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/"

HOWEVER, conf.get resolves base_url = in airflow.cfg to emptystring, and so at the end of this block, base_url == '' and not http://localhost:8080/, and default_execution_api_server == "/execution/"

What you think should happen instead?

I would generally think that an empty config value should be equivalent to a non-existent key, but maybe this there is some reason why conf.get works this way?

Regardless, it seems that if the LocalExecutor's execution_api_server_url ends up resolving to '/execution/' and sends that to airflow.sdk.execution_time.supervisor.supervise, it will always lead to a failure in the generation of a well formed URL, and this should throw a useful, readable error (thrown from either supervisor.py or local_executor.py)

How to reproduce

Set up a dockerized Airflow 3.0.2 runtime with LocalExecutor and set base_url = in airflow.cfg

Operating System

Linux / Docker image built from apache/airflow:3.0.2-python3.11

Versions of Apache Airflow Providers

No response

Deployment

Docker-Compose

Deployment details

No response

Anything else?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

Labels

area:Executors-coreLocalExecutor & SequentialExecutorarea:corekind:bugThis is a clearly a bugneeds-triagelabel for new issues that we didn't triage yet

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions