Skip to content

Make Edge executor adoption test immune to executor_loader reloads - #74122

Merged
henry3260 merged 1 commit into
apache:mainfrom
shahar1:fix-edge3-adopt-test-executor-loader-reload
Oct 3, 2026
Merged

henry3260 merged 1 commit into
apache:mainfrom
shahar1:fix-edge3-adopt-test-executor-loader-reload

Conversation

@shahar1

@shahar1 shahar1 commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

A test from #73832 started to fail suddenly - it didn't surface in the PR due to a bug in the selective checks.
This PR fixes the test, I'll handle the selective checks separately.

AI Summary

test_scheduler_restart_adopts_queued_edge_task (added in #73832) fails when the cncf.kubernetes and edge3 test suites run in the same pytest process, which is how CI groups them:

providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/executors/kubernetes_executor.py:182: in _list_pods
    dynamic_client = DynamicClient(self.kube_client.api_client)
E   AttributeError: 'NoneType' object has no attribute 'api_client'

Tests in other providers (cncf.kubernetes, celery) call importlib.reload() on airflow.executors.executor_loader. That replaces the ExecutorLoader class object in the module, while the module that builds the scheduler's executors keeps the class it imported at startup. The edge3 test patched init_executors through the module path, so the patch landed on the new class, the scheduler resolved executors through the original one, picked up the executor-name cache those tests leave populated with KubernetesExecutor, and called into an unstarted Kubernetes executor.

The test now patches init_executors on the class object held by the module that actually calls it: airflow.jobs.job on Airflow 3.0/3.1 and airflow.jobs.scheduler_job_runner on 3.2+ (the edge3 compat matrix covers 3.0.6, 3.1.8, 3.2.2 and 3.3.2).

Test-only change. The shipped edge_executor.py fix from #73832 is unaffected and works as released. Not fixing the leaking reloads in cncf.kubernetes/celery tests here; replacing those reload() calls with the clean_executor_loader fixture is a separate cleanup.

Verified locally with breeze testing providers-tests --test-type "Providers[cncf.kubernetes,edge3]": the test fails on main and passes with this change.


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

The scheduler-restart adoption test patched ExecutorLoader.init_executors
through the airflow.executors.executor_loader module path. Tests in other
providers (cncf.kubernetes, celery) call importlib.reload() on that module,
which replaces the ExecutorLoader class object there while the module that
builds the scheduler's executors keeps the original class. When those
providers run in the same pytest process before edge3, the patch lands on
the new class, the scheduler resolves executors through the old one and
picks up the leaked KubernetesExecutor name cache, and the test fails with
"'NoneType' object has no attribute 'api_client'".

Patch the class object on the module that actually calls init_executors(),
which differs between Airflow 3.0/3.1 (Job) and 3.2+ (SchedulerJobRunner).

@henry3260 henry3260 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.

Thanks

@henry3260
henry3260 merged commit 4c0ba9e into apache:main Oct 3, 2026
79 checks passed
@shahar1
shahar1 deleted the fix-edge3-adopt-test-executor-loader-reload branch October 3, 2026 04:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers provider:edge Edge Executor / Worker (AIP-69) / edge3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants