Skip to content

Unify executor workload queues#63491

Open
anishgirianish wants to merge 15 commits intoapache:mainfrom
anishgirianish:refactor-workload-queue
Open

Unify executor workload queues#63491
anishgirianish wants to merge 15 commits intoapache:mainfrom
anishgirianish:refactor-workload-queue

Conversation

@anishgirianish
Copy link
Contributor

@anishgirianish anishgirianish commented Mar 12, 2026


Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

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 overrode queue_workload also 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:

  • executor_queues: a single defaultdict(dict) keyed by workload type string (e.g. "ExecuteTask","ExecuteCallback") instead of separatequeued_tasks / queued_callbacks dicts
  • supported_workload_types: a frozenset of type strings instead of individual supports_callbacks booleans
  • WORKLOAD_TYPE_TIER + sort_key / queue_key : properties on each workload schema that control scheduling priority and queue indexing

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

  1. Define queue_key and sort_key on the workload schema
  2. Add the type string to supported_workload_types on supporting executors
  3. Handle the type in _process_workloads, done

No changes needed in BaseExecutor itself.


  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {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.

@boring-cyborg boring-cyborg bot added area:Executors-core LocalExecutor & SequentialExecutor area:providers provider:amazon AWS/Amazon - related issues provider:celery provider:cncf-kubernetes Kubernetes (k8s) provider related issues provider:edge Edge Executor / Worker (AIP-69) / edge3 labels Mar 12, 2026
Copy link
Contributor

@ferruzzi ferruzzi left a comment

Choose a reason for hiding this comment

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

Made a real quick pass and left some comments and questions, I'll try to get a more thorough one tomorrow.

@anishgirianish anishgirianish force-pushed the refactor-workload-queue branch 3 times, most recently from aee94fb to 8997ee4 Compare March 13, 2026 06:02
@anishgirianish anishgirianish marked this pull request as draft March 13, 2026 07:43
@anishgirianish anishgirianish force-pushed the refactor-workload-queue branch 6 times, most recently from 11ee7ef to 249b014 Compare March 14, 2026 04:40
@anishgirianish anishgirianish marked this pull request as ready for review March 14, 2026 05:45
@mock.patch("airflow.providers.celery.executors.celery_executor.CeleryExecutor.trigger_tasks")
@mock.patch(
"airflow.providers.celery.executors.celery_executor.CeleryExecutor."
+ ("trigger_workloads" if AIRFLOW_V_3_2_PLUS else "trigger_tasks")
Copy link
Contributor

Choose a reason for hiding this comment

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

Note: AIRFLOW_V_3_2_PLUS might need to be adjusted if this change does not make it into 3.2.0

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, solid point. At this point we should assume 3.3 I think. Pretty sure the 3.2 beta is already cut and we're not likely to get this in there.

@jscheffl jscheffl dismissed their stale review March 14, 2026 17:53

Blockers resolved, convinced me to un-block. Can make a second pass review if needed.

@anishgirianish anishgirianish force-pushed the refactor-workload-queue branch from 249b014 to c108d08 Compare March 15, 2026 19:56
@potiuk
Copy link
Member

potiuk commented Mar 16, 2026

@anishgirianish This PR has a few issues that need to be addressed before it can be reviewed — please see our Pull Request quality criteria.

Issues found:

  • ⚠️ Unresolved review comments: This PR has 3 unresolved review threads from maintainers: @ferruzzi (MEMBER): 1 unresolved threads; @jscheffl (MEMBER): 2 unresolved threads. Please review and resolve all inline review comments before requesting another review. You can resolve a conversation by clicking 'Resolve conversation' on each thread after addressing the feedback. See pull request guidelines.

Note: Your branch is 16 commits behind main. Some check failures may be caused by changes in the base branch rather than by your PR. Please rebase your branch and push again to get up-to-date CI results.

What to do next:

  • The comment informs you what you need to do.
  • Fix each issue, then mark the PR as "Ready for review" in the GitHub UI - but only after making sure that all the issues are fixed.
  • There is no rush — take your time and work at your own pace. We appreciate your contribution and are happy to wait for updates.
  • Maintainers will then proceed with a normal review.

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 anishgirianish force-pushed the refactor-workload-queue branch from 07187dc to b718b12 Compare March 16, 2026 15:10
@anishgirianish anishgirianish force-pushed the refactor-workload-queue branch 2 times, most recently from 3f7e866 to 3c89eeb Compare March 17, 2026 00:08
@anishgirianish anishgirianish force-pushed the refactor-workload-queue branch 2 times, most recently from eae4e00 to c8a4439 Compare March 17, 2026 02:43
@anishgirianish anishgirianish force-pushed the refactor-workload-queue branch from c8a4439 to 84c79cb Compare March 17, 2026 04:11
@anishgirianish anishgirianish requested a review from ferruzzi March 17, 2026 05:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Executors-core LocalExecutor & SequentialExecutor area:providers provider:amazon AWS/Amazon - related issues provider:celery provider:cncf-kubernetes Kubernetes (k8s) provider related issues provider:edge Edge Executor / Worker (AIP-69) / edge3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants