Skip to content

Conversation

@ftakelait
Copy link
Contributor

Summary

Migrates conf imports in the Celery provider from airflow.configuration to airflow.providers.common.compat.sdk for Airflow 3.x SDK compatibility.

Changes Made

Import Migration (9 files)

  • celery_executor.py
  • celery_executor_utils.py (2 imports)
  • celery_kubernetes_executor.py
  • celery_command.py
  • default_celery.py
  • Test files (4 files)

Fallback Parameters Added

Added fallback parameters to conf.get() calls that execute at module import time:

File Config Key Fallback
celery_executor.py FLOWER_HOST "0.0.0.0"
celery_executor.py FLOWER_PORT 5555
celery_executor.py FLOWER_URL_PREFIX ""
celery_executor.py FLOWER_BASIC_AUTH ""
celery_executor.py DEFAULT_QUEUE "default"
celery_executor.py worker_concurrency 16
celery_executor.py SYNC_PARALLELISM 0
celery_executor.py task_publish_max_retries 3
celery_executor_utils.py operation_timeout 1.0
celery_executor_utils.py CELERY_APP_NAME "airflow.executors.celery_executor"
default_celery.py SSL_ACTIVE False

Why fallbacks are needed?

The SDK conf.get() is stricter than airflow.configuration.conf.get() - it raises AirflowConfigException when a key is not found instead of returning None. This was causing test collection failures when config keys were accessed at module import time before provider configuration was loaded.

Part of #60000

ARG_BROKER_API = Arg(("-a", "--broker-api"), help="Broker API")
ARG_FLOWER_HOSTNAME = Arg(
("-H", "--hostname"),
default=conf.get("celery", "FLOWER_HOST"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need defaults?

@ftakelait ftakelait requested a review from sunank200 January 2, 2026 17:48
@potiuk
Copy link
Member

potiuk commented Jan 7, 2026

Still working on it @ftakelait ? are you going to rebase and fix the comments ?

@ftakelait
Copy link
Contributor Author

Still working on it @ftakelait ? are you going to rebase and fix the comments ?

Hi @potiuk, I am still waiting for @sunank200 to reply about whether I should keep the fallback or I baypass the testing stage.

@potiuk
Copy link
Member

potiuk commented Jan 7, 2026

I have not seen your question - it's not visible here - I don't think @sunank200 is rather waiting for you - looking at the comments in PR.

#60074 (comment) is where we discussed how to fix it - and hopefully it will be fixed there

But you can still rebase though and keep on solving conflicts. That would be my recommendation while waiting for mechanism implemented for k8s

Replace imports of `from airflow.configuration import conf` with
`from airflow.providers.common.compat.sdk import conf` for Airflow 3.x
compatibility.

Add fallback parameters to conf.get() calls that execute at module
import time to prevent AirflowConfigException when config keys are
not yet loaded.

Part of apache#60000

Signed-off-by: Fouzi Takelait <[email protected]>
@ftakelait ftakelait force-pushed the fix/60000-celery-conf-sdk-migration branch from 02f5850 to 5c615be Compare January 10, 2026 12:48
@ftakelait
Copy link
Contributor Author

ftakelait commented Jan 10, 2026

Rebased the PR. I'll wait for the configuration mechanism being developed in #60074, then update this PR to use it instead of individual fallbacks.

@ftakelait ftakelait closed this Jan 10, 2026
@ftakelait ftakelait reopened this Jan 10, 2026
Copy link
Member

Choose a reason for hiding this comment

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

There are unresolved conflict markers here.

@uranusjr
Copy link
Member

Why do we need to add fallbacks to many configs? Did they not work without the fallbacks?

@potiuk
Copy link
Member

potiuk commented Jan 15, 2026

Why do we need to add fallbacks to many configs? Did they not work without the fallbacks?

@uranusjr -> This is manifestation of doing too much and in a wrong sequence during imports. The problem is that currently the sdk config does not have the defaults "hard-coded" fallbacks for celery and kubernetes providers (@amoghrajesh deliberately skipped them when moving conf to task.sdk) - because initialization of executors (that already need those fallbacks) is happening during importing airflow and before provider's manager initializes configuration retrieved from providers. This has been discussed and I proposed to bring it back as a temporary solution before we finish task isolation and will be able to do explicit initialization rather than import-based initialization: #60074 (comment)

But maybe there are other proposals?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants