Skip to content

AIP-67 - Multi Team: Update Celery Executor to support multi team#60675

Merged
dheerajturaga merged 16 commits intoapache:mainfrom
aws-mwaa:onikolas/multi_team_celery_executor
Jan 30, 2026
Merged

AIP-67 - Multi Team: Update Celery Executor to support multi team#60675
dheerajturaga merged 16 commits intoapache:mainfrom
aws-mwaa:onikolas/multi_team_celery_executor

Conversation

@o-nikolas
Copy link
Contributor

@o-nikolas o-nikolas commented Jan 17, 2026

Updating the Celery executor to read from team based config and also support multiple instances running concurrently.

The latter is the largest source of changes. Much of the celery configuration (both Airflow config and Celery config) was module based. Modules are cached and shared in Python. So the majority of the changes are moving that module level config code to be function based (while trying to also maintain backwards compatibility).

The way Celery tasks are sent to workers also changed as a consequence of this. Since sending tasks is parallelized with multiple processes (which do not share memory with the parent) the send task logic now re-creates a celery app in the sub processes (since the pickling and unpickling that python does to try pass state to the sub processes was not reliably creating the correct celery app objects).


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

  • 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 or {issue_number}.significant.rst, in airflow-core/newsfragments.

Updating the Celery executor to read from team based config and also
support multiple instances running concurrently.

The latter is the largest source of changes. Much of the celery
configuration (both Airflow config and Celery config) was module based.
Modules are cached and shared in Python. So the majority of the changes
are moving that module level config code to be function based (while
trying to also maintain backwards compatibility).

The way Celery tasks are sent to workers also changed as a consequence
of this. Since sending tasks is parallelized with multiple processes
(which do not share memory with the parent) the send task logic now
re-creates a celery app in the sub processes (since the pickling and
unpickling that python does to try pass state to the sub processes was
not reliably creating the correct celery app objects).
@o-nikolas o-nikolas added full tests needed We need to run full set of tests for this PR to merge multi-team - aip-67 Issues related to multi-team (AIP-67) labels Jan 17, 2026
Copy link
Member

@dheerajturaga dheerajturaga left a comment

Choose a reason for hiding this comment

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

Thanks for the enhancements! the current implementation introduces static type errors that will fail our CI pipeline. I have provided inline patches to correct the type signatures and ensure compliance with our MyPy configuration.

@dheerajturaga
Copy link
Member

@o-nikolas I have tested the general functionality of celery worker with your changes as well as tested out the CLI. Things are working as expected. However, I don't see how I can test the --team option. Seems like if I set a team the jobs still seem to be launching on the worker. How do you propose I test the multi team support here?

@o-nikolas o-nikolas requested a review from vincbeck January 19, 2026 17:38
@o-nikolas
Copy link
Contributor Author

@o-nikolas I have tested the general functionality of celery worker with your changes as well as tested out the CLI. Things are working as expected. However, I don't see how I can test the --team option. Seems like if I set a team the jobs still seem to be launching on the worker. How do you propose I test the multi team support here?

Thanks for the thorough review @dheerajturaga! I've addressed those issues (slightly differently for one than your suggested patch). I'm currently struggling with back compat tests. It's slow/difficult because those tests to do not run successfully in breeze on my laptop. So I have to push to the PR to test each change.

As far as testing with the --team flag. For this you have to have a full multi-team setup, which we don't have great documentation for yet (coming soon). The most helpful testing is actually on the backcompat side (testing with airflow 2.11 and 3.1.X)

Copy link
Member

@dheerajturaga dheerajturaga left a comment

Choose a reason for hiding this comment

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

@o-nikolas , I have run backward compatibility checks. Things work good in 2.11.0 however when I tried this with 3.1.3 I found issues. There are incomplete API contract in the ExecutorConf class between Airflow versions.

@dheerajturaga dheerajturaga self-requested a review January 29, 2026 23:17
Copy link
Member

@dheerajturaga dheerajturaga left a comment

Choose a reason for hiding this comment

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

Hopefully the final set of changes needed to be consistent. Everything else looks good.

Co-authored-by: Dheeraj Turaga <dheerajturaga@gmail.com>
@o-nikolas o-nikolas dismissed dheerajturaga’s stale review January 30, 2026 17:41

Request for changes has been left after fixes were applied.

Copy link
Member

@dheerajturaga dheerajturaga left a comment

Choose a reason for hiding this comment

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

Awesome! Thanks so much for your patience, I know there was a lot of back and forth. Current changes look good!

@dheerajturaga dheerajturaga merged commit 58f785a into apache:main Jan 30, 2026
129 checks passed
@o-nikolas
Copy link
Contributor Author

Awesome! Thanks so much for your patience, I know there was a lot of back and forth. Current changes look good!

No worries @dheerajturaga! I appreciate the thorough review and testing :) I made sure to commit one of your suggestions to get you tagged as a co-author for your efforts!

morelgeorge pushed a commit to morelgeorge/airflow that referenced this pull request Feb 1, 2026
…ache#60675)

* Update Celery Executor to support multi team

Updating the Celery executor to read from team based config and also
support multiple instances running concurrently.

The latter is the largest source of changes. Much of the celery
configuration (both Airflow config and Celery config) was module based.
Modules are cached and shared in Python. So the majority of the changes
are moving that module level config code to be function based (while
trying to also maintain backwards compatibility).

The way Celery tasks are sent to workers also changed as a consequence
of this. Since sending tasks is parallelized with multiple processes
(which do not share memory with the parent) the send task logic now
re-creates a celery app in the sub processes (since the pickling and
unpickling that python does to try pass state to the sub processes was
not reliably creating the correct celery app objects).

* Fixes from PR CI

* Mypy sometimes makes code worse

* Fallback to global conf if we're not running on 3.2+ airflow

As inferred by the presence of the correct ExecutorConf methods being
available.

* More backcompat

* Skip multi team tests if not 3.2

* 3.2 not 3.1

* Add type annotation for create_celery_app

* Conditional or TYPE_CHECKING imports of ExercutorConfig

* More type fixups

* Use explicit version compat checks rather than trying to infer

* Test back compat on celery command

* fixup

* Apply suggestions from code review

Co-authored-by: Dheeraj Turaga <dheerajturaga@gmail.com>

* New exception for unit test

---------

Co-authored-by: Dheeraj Turaga <dheerajturaga@gmail.com>
dheerajturaga added a commit to dheerajturaga/airflow that referenced this pull request Feb 1, 2026
…n test

  The test constructed ExecuteTask and TaskInstance via model_construct(),
  which bypasses Pydantic validation. Fields added or made required by
  apache#50825 (dag_version_id, pool_slots) and inherited from BaseDagBundleWorkload
  (token, dag_rel_path, bundle_info, log_path) were missing. This went
  unnoticed until apache#60675 changed task dispatch to run in ProcessPoolExecutor
  subprocesses where mock patches don't apply, causing the real
  execute_workload (with full schema validation) to run on the worker.
shashbha14 pushed a commit to shashbha14/airflow that referenced this pull request Feb 2, 2026
…ache#60675)

* Update Celery Executor to support multi team

Updating the Celery executor to read from team based config and also
support multiple instances running concurrently.

The latter is the largest source of changes. Much of the celery
configuration (both Airflow config and Celery config) was module based.
Modules are cached and shared in Python. So the majority of the changes
are moving that module level config code to be function based (while
trying to also maintain backwards compatibility).

The way Celery tasks are sent to workers also changed as a consequence
of this. Since sending tasks is parallelized with multiple processes
(which do not share memory with the parent) the send task logic now
re-creates a celery app in the sub processes (since the pickling and
unpickling that python does to try pass state to the sub processes was
not reliably creating the correct celery app objects).

* Fixes from PR CI

* Mypy sometimes makes code worse

* Fallback to global conf if we're not running on 3.2+ airflow

As inferred by the presence of the correct ExecutorConf methods being
available.

* More backcompat

* Skip multi team tests if not 3.2

* 3.2 not 3.1

* Add type annotation for create_celery_app

* Conditional or TYPE_CHECKING imports of ExercutorConfig

* More type fixups

* Use explicit version compat checks rather than trying to infer

* Test back compat on celery command

* fixup

* Apply suggestions from code review

Co-authored-by: Dheeraj Turaga <dheerajturaga@gmail.com>

* New exception for unit test

---------

Co-authored-by: Dheeraj Turaga <dheerajturaga@gmail.com>
jason810496 pushed a commit to abhijeets25012-tech/airflow that referenced this pull request Feb 3, 2026
…ache#60675)

* Update Celery Executor to support multi team

Updating the Celery executor to read from team based config and also
support multiple instances running concurrently.

The latter is the largest source of changes. Much of the celery
configuration (both Airflow config and Celery config) was module based.
Modules are cached and shared in Python. So the majority of the changes
are moving that module level config code to be function based (while
trying to also maintain backwards compatibility).

The way Celery tasks are sent to workers also changed as a consequence
of this. Since sending tasks is parallelized with multiple processes
(which do not share memory with the parent) the send task logic now
re-creates a celery app in the sub processes (since the pickling and
unpickling that python does to try pass state to the sub processes was
not reliably creating the correct celery app objects).

* Fixes from PR CI

* Mypy sometimes makes code worse

* Fallback to global conf if we're not running on 3.2+ airflow

As inferred by the presence of the correct ExecutorConf methods being
available.

* More backcompat

* Skip multi team tests if not 3.2

* 3.2 not 3.1

* Add type annotation for create_celery_app

* Conditional or TYPE_CHECKING imports of ExercutorConfig

* More type fixups

* Use explicit version compat checks rather than trying to infer

* Test back compat on celery command

* fixup

* Apply suggestions from code review

Co-authored-by: Dheeraj Turaga <dheerajturaga@gmail.com>

* New exception for unit test

---------

Co-authored-by: Dheeraj Turaga <dheerajturaga@gmail.com>
jhgoebbert pushed a commit to jhgoebbert/airflow that referenced this pull request Feb 4, 2026
…ache#60675)

* Update Celery Executor to support multi team

Updating the Celery executor to read from team based config and also
support multiple instances running concurrently.

The latter is the largest source of changes. Much of the celery
configuration (both Airflow config and Celery config) was module based.
Modules are cached and shared in Python. So the majority of the changes
are moving that module level config code to be function based (while
trying to also maintain backwards compatibility).

The way Celery tasks are sent to workers also changed as a consequence
of this. Since sending tasks is parallelized with multiple processes
(which do not share memory with the parent) the send task logic now
re-creates a celery app in the sub processes (since the pickling and
unpickling that python does to try pass state to the sub processes was
not reliably creating the correct celery app objects).

* Fixes from PR CI

* Mypy sometimes makes code worse

* Fallback to global conf if we're not running on 3.2+ airflow

As inferred by the presence of the correct ExecutorConf methods being
available.

* More backcompat

* Skip multi team tests if not 3.2

* 3.2 not 3.1

* Add type annotation for create_celery_app

* Conditional or TYPE_CHECKING imports of ExercutorConfig

* More type fixups

* Use explicit version compat checks rather than trying to infer

* Test back compat on celery command

* fixup

* Apply suggestions from code review

Co-authored-by: Dheeraj Turaga <dheerajturaga@gmail.com>

* New exception for unit test

---------

Co-authored-by: Dheeraj Turaga <dheerajturaga@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers full tests needed We need to run full set of tests for this PR to merge multi-team - aip-67 Issues related to multi-team (AIP-67) provider:celery

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants