Skip to content

Fix airflowctl retry env-var tests failing on self-hosted runners - #73212

Merged
shahar1 merged 1 commit into
apache:mainfrom
shahar1:fix-airflowctl-retry-env-test
Sep 15, 2026
Merged

shahar1 merged 1 commit into
apache:mainfrom
shahar1:fix-airflowctl-retry-env-test

Conversation

@shahar1

@shahar1 shahar1 commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Human Summary

The module-level unique_config_dir fixture was accidentally replacing the entire environment with just AIRFLOW_HOME before starting a second Python process.
When running on self-hosted runners (currently WIIP), this dropped LD_LIBRARY_PATH, which the actions/setup-python interpreter needs to find its shared libraries.

The fix was to make this test class preserve the normal environment, point AIRFLOW_HOME to a temporary directory, and clear only the specific AIRFLOW_CLI_API_* variables being tested. Other tests still use the fully isolated environment.

AI Summary

Click Here The autouse `unique_config_dir` fixture in `test_client.py` runs `patch.dict(os.environ, ..., clear=True)`, so `TestRetryConfigurationEnvVars` spawned its child interpreter with an environment containing only `AIRFLOW_HOME` (no `PATH`, no `LD_LIBRARY_PATH`).

A Python installed by actions/setup-python is built --enable-shared with an RPATH pointing at /opt/hostedtoolcache/.... On GitHub-hosted runners that path exists, so the child started by luck. On a self-hosted runner the toolcache lives elsewhere and the interpreter depends on the LD_LIBRARY_PATH that setup-python exports, so the child died before importing anything:

.venv/bin/python: error while loading shared libraries: libpython3.10.so.1.0: cannot open shared object file: No such file or directory

This overrides the fixture at class scope: the child inherits the real environment, and only the AIRFLOW_CLI_API_* knobs under test are removed so a developer's shell values cannot skew the expected results. The rest of the module keeps the strict cleared environment.

Verified with --setup-show that the class-level override is the fixture that runs, and the full module passes under -n 4.


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Fable 5.1)

Generated-by: Claude Code (Fable 5.1) following the guidelines

🤖 Generated with Claude Code

The module-wide autouse fixture clears os.environ, so the retry tests
handed a child interpreter an environment with nothing but AIRFLOW_HOME.
A Python built with --enable-shared then cannot locate libpython unless
LD_LIBRARY_PATH survives, which is exactly what actions/setup-python
relies on outside /opt/hostedtoolcache. The tests only passed on
GitHub-hosted runners because the hardcoded RPATH happened to resolve.

Override the fixture for that class so the child inherits a real
environment, and drop only the AIRFLOW_CLI_API_* knobs under test so a
developer's shell cannot influence the result.

@henry3260 henry3260 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@SameerMesiah97 SameerMesiah97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me save for one unrelated CI failure. Also, just had a question I would hope you could answer as a maintainer.

@shahar1
shahar1 merged commit b6f61b5 into apache:main Sep 15, 2026
181 of 186 checks passed
@shahar1
shahar1 deleted the fix-airflowctl-retry-env-test branch September 15, 2026 19:47
@github-actions

Copy link
Copy Markdown
Contributor

Backport successfully created: airflow-ctl/v0-1-test

Note: As of Merging PRs targeted for Airflow 3.X
the committer who merges the PR is responsible for backporting the PRs that are bug fixes (generally speaking) to the maintenance branches.

In matter of doubt please ask in #release-management Slack channel.

Status Branch Result
✅ airflow-ctl/v0-1-test PR Link

github-actions Bot pushed a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Sep 15, 2026
… self-hosted runners (apache#73212)

The module-wide autouse fixture clears os.environ, so the retry tests
handed a child interpreter an environment with nothing but AIRFLOW_HOME.
A Python built with --enable-shared then cannot locate libpython unless
LD_LIBRARY_PATH survives, which is exactly what actions/setup-python
relies on outside /opt/hostedtoolcache. The tests only passed on
GitHub-hosted runners because the hardcoded RPATH happened to resolve.

Override the fixture for that class so the child inherits a real
environment, and drop only the AIRFLOW_CLI_API_* knobs under test so a
developer's shell cannot influence the result.
(cherry picked from commit b6f61b5)

Co-authored-by: Shahar Epstein <[email protected]>
shahar1 added a commit that referenced this pull request Sep 15, 2026
… self-hosted runners (#73212) (#73223)

The module-wide autouse fixture clears os.environ, so the retry tests
handed a child interpreter an environment with nothing but AIRFLOW_HOME.
A Python built with --enable-shared then cannot locate libpython unless
LD_LIBRARY_PATH survives, which is exactly what actions/setup-python
relies on outside /opt/hostedtoolcache. The tests only passed on
GitHub-hosted runners because the hardcoded RPATH happened to resolve.

Override the fixture for that class so the child inherits a real
environment, and drop only the AIRFLOW_CLI_API_* knobs under test so a
developer's shell cannot influence the result.
(cherry picked from commit b6f61b5)

Co-authored-by: Shahar Epstein <[email protected]>
shahar1 added a commit that referenced this pull request Nov 19, 2026
… self-hosted runners (#73212) (#73223)

The module-wide autouse fixture clears os.environ, so the retry tests
handed a child interpreter an environment with nothing but AIRFLOW_HOME.
A Python built with --enable-shared then cannot locate libpython unless
LD_LIBRARY_PATH survives, which is exactly what actions/setup-python
relies on outside /opt/hostedtoolcache. The tests only passed on
GitHub-hosted runners because the hardcoded RPATH happened to resolve.

Override the fixture for that class so the child inherits a real
environment, and drop only the AIRFLOW_CLI_API_* knobs under test so a
developer's shell cannot influence the result.
(cherry picked from commit b6f61b5)

Co-authored-by: Shahar Epstein <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants