Skip to content

fix: ensure execute_command is registered with Celery app at worker s…#63050

Closed
kalluripradeep wants to merge 4 commits intoapache:v2-11-testfrom
kalluripradeep:fix-celery-executor-init
Closed

fix: ensure execute_command is registered with Celery app at worker s…#63050
kalluripradeep wants to merge 4 commits intoapache:v2-11-testfrom
kalluripradeep:fix-celery-executor-init

Conversation

@kalluripradeep
Copy link
Copy Markdown
Contributor

When the Celery worker starts, it imports app from celery_executor.py but celery_executor_utils.py was never imported at module level. This means execute_command never gets registered as a Celery task when the worker boots, and the celery_import_modules signal handler never connects.

This worked before because older Celery versions were more lenient about when tasks got registered. Celery provider 3.17.0 exposed this — workers start receiving messages before _process_tasks() is ever called, so execute_command is unknown and messages get discarded:
KeyError: 'execute_command'
Received unregistered task of type 'execute_command'. The message has been ignored and discarded.

Fix is a single import in celery_executor.py so celery_executor_utils is loaded when the worker imports app at startup.

Fixes #63043

Copy link
Copy Markdown
Member

@potiuk potiuk left a comment

Choose a reason for hiding this comment

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

Nice! Thanks for investigation!

@potiuk potiuk added the full tests needed We need to run full set of tests for this PR to merge label Mar 7, 2026
@potiuk potiuk force-pushed the fix-celery-executor-init branch from 280c641 to 1eb4a9e Compare March 7, 2026 18:56
@potiuk
Copy link
Copy Markdown
Member

potiuk commented Mar 7, 2026

I added full_tests_needed to see if the prod image will be built and docker-compose tests run

@potiuk potiuk requested review from eladkal and o-nikolas March 7, 2026 18:59
@potiuk
Copy link
Copy Markdown
Member

potiuk commented Mar 7, 2026

Nope. @kalluripradeep -> it does not seem to fix the problem.

Copy link
Copy Markdown
Member

@potiuk potiuk left a comment

Choose a reason for hiding this comment

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

Looks like the problem is not fixed

@potiuk
Copy link
Copy Markdown
Member

potiuk commented Mar 7, 2026

same error:

  The delivery info for this task is:
  {'exchange': '', 'routing_key': 'default'}
  Traceback (most recent call last):
    File "/home/airflow/.local/lib/python3.10/site-packages/celery/worker/consumer/consumer.py", line 668, in on_task_received
      strategy = strategies[type_]
  KeyError: 'execute_command'

@kalluripradeep
Copy link
Copy Markdown
Contributor Author

@potiuk — the fix is correct but the docker-compose test installs apache-airflow-providers-celery==3.17.0 from PyPI on top of the base image, so it doesn't pick up the change from this branch. The fix needs to be in the provider package and released as a new version. Should this PR target the provider package source instead, so it gets included in 3.17.1?

@kalluripradeep kalluripradeep requested a review from potiuk March 7, 2026 21:48
@potiuk
Copy link
Copy Markdown
Member

potiuk commented Mar 7, 2026

@potiuk — the fix is correct but the docker-compose test installs apache-airflow-providers-celery==3.17.0 from PyPI on top of the base image, so it doesn't pick up the change from this branch. The fix needs to be in the provider package and released as a new version. Should this PR target the provider package source instead, so it gets included in 3.17.1?

Yes. Initially the cahnge was to "airflow-core" - but since you changed it now to providers, it needs to be done for main and indeed next versioin of celery provider. Which is what I kind of expected. Closing it - open a new one for main and in the meantime #63046 should be merged to release 2.11.2

@kalluripradeep
Copy link
Copy Markdown
Contributor Author

@potiuk — the fix is correct but the docker-compose test installs apache-airflow-providers-celery==3.17.0 from PyPI on top of the base image, so it doesn't pick up the change from this branch. The fix needs to be in the provider package and released as a new version. Should this PR target the provider package source instead, so it gets included in 3.17.1?

Yes. Initially the cahnge was to "airflow-core" - but since you changed it now to providers, it needs to be done for main and indeed next versioin of celery provider. Which is what I kind of expected. Closing it - open a new one for main and in the meantime #63046 should be merged to release 2.11.2

@potiuk — opened #63110 targeting main with the same fix plus a regression test. Module-level import of celery_executor_utils in celery_executor.py so execute_workload and execute_command are registered when the worker boots.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full tests needed We need to run full set of tests for this PR to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants