Unify executor workload queues#63491
Conversation
85bfce8 to
1ce0748
Compare
ferruzzi
left a comment
There was a problem hiding this comment.
Made a real quick pass and left some comments and questions, I'll try to get a more thorough one tomorrow.
aee94fb to
8997ee4
Compare
11ee7ef to
249b014
Compare
kaxil
left a comment
There was a problem hiding this comment.
Left 8 inline comments on this PR.
There was a problem hiding this comment.
Pull request overview
Refactors Airflow executor workload queue management to use a unified, type-driven queue structure (instead of per-workload dicts and per-feature flags), aiming to make new workload types easier to add while keeping scheduling/slot behavior consistent.
Changes:
- Introduces
WorkloadType,WORKLOAD_TYPE_TIER, and per-workloadqueue_key/sort_keyto drive queueing and scheduling. - Replaces
queued_tasks/queued_callbacksinternal storage withBaseExecutor.executor_queuesand replacessupports_callbackswithsupported_workload_types(with deprecation shims). - Renames scheduling entrypoint from
trigger_taskstotrigger_workloadsand updates core/provider tests accordingly.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| airflow-core/src/airflow/executors/base_executor.py | Core refactor: unified executor_queues, supported_workload_types, trigger_workloads, and backward-compat properties. |
| airflow-core/src/airflow/executors/local_executor.py | Updates LocalExecutor to use unified queues and generic dequeue by queue_key. |
| airflow-core/src/airflow/executors/workloads/base.py | Adds WorkloadType registry and WORKLOAD_TYPE_TIER plus base queue_key/sort_key API. |
| airflow-core/src/airflow/executors/workloads/task.py | Makes ExecuteTask.type use WorkloadType and adds queue_key/sort_key. |
| airflow-core/src/airflow/executors/workloads/callback.py | Makes ExecuteCallback.type use WorkloadType and adds queue_key. |
| airflow-core/src/airflow/executors/workloads/types.py | Adds QueueableWorkload type alias for workloads that flow through executor queues. |
| airflow-core/src/airflow/executors/workloads/init.py | Exports WorkloadType and WORKLOAD_TYPE_TIER from the workloads package. |
| airflow-core/tests/unit/executors/test_base_executor.py | Updates tests to new APIs; adds coverage for backward-compat properties. |
| airflow-core/tests/unit/executors/test_local_executor.py | Updates tests to new unified queue access patterns. |
| devel-common/src/tests_common/test_utils/mock_executor.py | Updates mock executor to use executor_queues keyed by WorkloadType. |
| devel-common/src/tests_common/test_utils/version_compat.py | Adds AIRFLOW_V_3_3_PLUS test constant for compatibility branching. |
| providers/celery/src/airflow/providers/celery/executors/celery_executor.py | Switches CeleryExecutor to supported_workload_types instead of supports_callbacks. |
| providers/celery/src/airflow/providers/celery/executors/celery_kubernetes_executor.py | Updates queued task merging implementation (copy/update instead of dict union). |
| providers/celery/tests/unit/celery/executors/test_celery_executor.py | Updates test patching for renamed trigger method (currently version-gated). |
| providers/celery/tests/integration/celery/test_celery_executor.py | Updates integration test to call trigger_workloads. |
| providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/executors/kubernetes_executor.py | Removes legacy TYPE_CHECKING queued_tasks typing branch. |
| providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/executors/local_kubernetes_executor.py | Adjusts queued task merging implementation (copy/update) and adds type-ignore/TODO. |
| providers/cncf/kubernetes/tests/unit/cncf/kubernetes/executors/test_kubernetes_executor.py | Updates test patching for renamed trigger method (currently version-gated). |
| providers/amazon/src/airflow/providers/amazon/aws/executors/ecs/ecs_executor.py | Removes legacy TYPE_CHECKING queued_tasks typing branch. |
| providers/amazon/src/airflow/providers/amazon/aws/executors/batch/batch_executor.py | Removes legacy TYPE_CHECKING queued_tasks typing branch and unused version compat import. |
| providers/amazon/src/airflow/providers/amazon/aws/executors/aws_lambda/lambda_executor.py | Removes legacy TYPE_CHECKING queued_tasks typing branch and unused version compat import. |
| providers/edge3/tests/unit/edge3/executors/test_edge_executor.py | Adjusts test setup to mutate queued tasks mapping in-place. |
| providers/cncf/kubernetes/tests/unit/cncf/kubernetes/executors/test_kubernetes_executor.py | Imports new AIRFLOW_V_3_3_PLUS and gates patch target between old/new method name. |
f476d34 to
7d6c856
Compare
|
@anishgirianish This PR has been converted to draft because it does not yet meet our Pull Request quality criteria. Issues found:
What to do next:
Converting a PR to draft is not a rejection — it is an invitation to bring the PR up to the project's standards so that maintainer review time is spent productively. There is no rush — take your time and work at your own pace. We appreciate your contribution and are happy to wait for updates. If you have questions, feel free to ask on the Airflow Slack. |
7d6c856 to
48096b8
Compare
|
@anishgirianish This PR has been converted to draft because it does not yet meet our Pull Request quality criteria. Issues found:
What to do next:
Converting a PR to draft is not a rejection — it is an invitation to bring the PR up to the project's standards so that maintainer review time is spent productively. There is no rush — take your time and work at your own pace. We appreciate your contribution and are happy to wait for updates. If you have questions, feel free to ask on the Airflow Slack. |
|
@anishgirianish This PR has been converted to draft because it does not yet meet our Pull Request quality criteria. Issues found:
What to do next:
Converting a PR to draft is not a rejection — it is an invitation to bring the PR up to the project's standards so that maintainer review time is spent productively. There is no rush — take your time and work at your own pace. We appreciate your contribution and are happy to wait for updates. If you have questions, feel free to ask on the Airflow Slack. |
|
You got asked to fix the issues - before marking it ready . Don't do it next time. |
48096b8 to
cdf8b9b
Compare
Hi @potiuk, Thank you so much for taking the time to review and for all the work you do maintaining the triage process. I truly appreciate it. I sincerely apologize for marking the PR as ready without resolving the merge conflicts first. That was my mistake, and I completely understand why it was flagged. I'll be more careful going forward and will make sure everything is in order before marking ready again. Thank you for pointing that out it helps me learn the process better. I had a question about the provider test failures and would really appreciate your guidance. The few failing tests regarding providers are related to the trigger_tasks AttributeError, No module named'airflow.executors.workloads', 'KubernetesExecutor' has no attribute 'executor_queues' that this PR introduces for 3.3. The tests already have a version guard using AIRFLOW_V_3_3_PLUS to handle backward compatibility, but since main is currently on 3.2, the flag evaluates to False and the tests try to mock the old method name, which no longer exists on this branch. Would the correct approach be to keep this PR in draft state until main moves to 3.3, and then rebase and mark it ready at that point? I'd love to know what you'd recommend so I can follow the right process. Thank you so much for your patience and guidance! |
809de6c to
d9b1252
Compare
I think we should change the version to 3.3 about now (@rahulvats) ? Though the thing is that compatibility tests should be adapted to compat tests - this comment when they fail explain it and links to the docs about it:
|
|
@seanghaeli - With #62645 merged, this is the next big piece of the puzzle. |
be14b1e to
0f6f172
Compare
0f6f172 to
35a927f
Compare
Was generative AI tooling used to co-author this PR?
Summary
Refactors executor workload queue management for extensibility. No behavioral change , scheduling order, slot accounting, and all provider executors work identically to before.
Follows the direction proposed by @ferruzzi #62343 (comment).
Problem
Adding a new workload type (like ExecuteCallback or TestConnection) required touching ~6 places in BaseExecutor: a new queue dict, a new
supports_*flag,slots calculation, an isinstance branch in queue_workload, a dedicated scheduling method, and isinstance branches in dequeue/trigger logic. Each provider executor that overrodequeue_workloadalso needed updating. This made extending the executor interface unnecessarily painful.What this does
Replaces the per-type queue dicts and boolean capability flags with three simple primitives:
The base class queue_workload is now generic: validate the type, store by key. Four provider executors (K8s, ECS, Batch, Lambda) no longer need their own queue_workload overrides. trigger_tasks becomes trigger_workloads since it handles all workload types now.
Adding a new workload type after this refactor
No changes needed in BaseExecutor itself.
{pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.