Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix KEDA Query to Use executor Field Instead of queue for Multiple Executors#52840

Merged
romsharon98 merged 2 commits intoapache:mainfrom
HsiuChuanHsu:bug/keda-query-executor-mismatch
Jul 18, 2025
Merged

Fix KEDA Query to Use executor Field Instead of queue for Multiple Executors#52840
romsharon98 merged 2 commits intoapache:mainfrom
HsiuChuanHsu:bug/keda-query-executor-mismatch

Conversation

Copy link
Contributor

HsiuChuanHsu commented Jul 4, 2025 *
edited by eladkal
Loading

Description:

When multiple executors (e.g., CeleryExecutor,KubernetesExecutor) are configured, the worker default KEDA query uses the queue column in the Airflow metadata database to determine Celery worker scaling.
However, task routing in Airflow is based on the executor attribute, not queue. This causes Celery workers to scale up unnecessarily for tasks explicitly configured with executor='KubernetesExecutor' but using the default queue

Changes:

This PR updates the KEDA query logic in values.yaml to correctly filter tasks based on the executor field when multiple executors are configured:

  • For CeleryKubernetesExecutor, the existing logic is retained, using queue != '{{ .Values.config.celery_kubernetes_executor.kubernetes_queue }}'.
  • For configurations including KubernetesExecutor (alone or with CeleryExecutor), the query is updated to use executor != 'KubernetesExecutor' ensuring tasks assigned to KubernetesExecutor not trigger Celery worker scaling.

Testing Steps

  1. Deploy Airflow using Helm Chart with KEDA enabled and multiple executors:
executor: CeleryExecutor,KubernetesExecutor
workers:
keda:
enabled: true
  1. Create a DAG with tasks explicitly using KubernetesExecutor and queue='default'
  2. Verify that Celery workers do not scale up for tasks with executor='KubernetesExecutor'

Additional Notes:

Related Issues:

Closes: #49001


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

HsiuChuanHsu requested review from dstandish, hussein-awala and jedcunningham as code owners July 4, 2025 05:36
boring-cyborg bot added the area:helm-chart Airflow Helm Chart label Jul 4, 2025
eladkal requested a review from romsharon98 July 8, 2025 13:48
romsharon98 approved these changes Jul 8, 2025
Copy link
Contributor

romsharon98 commented Jul 8, 2025

Tests need to be fixed

HsiuChuanHsu reacted with heart emoji

HsiuChuanHsu requested review from XD-DENG and rawwar as code owners July 10, 2025 15:08
jason810496 approved these changes Jul 11, 2025
Copy link
Member

jason810496 left a comment

Choose a reason for hiding this comment

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

Nice catch!

HsiuChuanHsu reacted with hooray emoji
amoghrajesh approved these changes Jul 11, 2025
eladkal added this to the Airflow Helm Chart 1.19.0 milestone Jul 11, 2025
bugraoz93 approved these changes Jul 11, 2025
Copy link
Contributor

bugraoz93 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 changes! Could you please rebase it before merging it? The PR has 137 commits

Copy link
Contributor

bugraoz93 commented Jul 11, 2025

I think you are merging the changes. You need to rebase from master and force push changes to your branch.

HsiuChuanHsu reacted with heart emoji

HsiuChuanHsu added 2 commits July 12, 2025 07:32
- Update workers.keda.query in values.yaml to check executor attribute
- Modified the KEDA autoscaling query in values.schema.json to handle KubernetesExecutor
separately from CeleryKubernetesExecutor, ensuring tasks with KubernetesExecutor
are filtered by executor type instead of queue name.
- Updated the corresponding logic in test_keda.py to reflect the new query structure,
improving test accuracy for KubernetesExecutor scenarios.
HsiuChuanHsu force-pushed the bug/keda-query-executor-mismatch branch from b749ba9 to 15b0e67 Compare July 11, 2025 23:32
Copy link
Contributor Author

HsiuChuanHsu commented Jul 11, 2025

I think I changed it correctly this time! Thanks a lot for the help!

Copy link
Contributor

bugraoz93 commented Jul 12, 2025

This is it, thanks! :)

romsharon98 merged commit 52f3a44 into apache:main Jul 18, 2025
71 checks passed
Copy link

boring-cyborg bot commented Jul 18, 2025

Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions.

karenbraganz pushed a commit to karenbraganz/airflow that referenced this pull request Jul 18, 2025
HsiuChuanHsu deleted the bug/keda-query-executor-mismatch branch September 9, 2025 22:18
jedcunningham mentioned this pull request Jan 30, 2026
98 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

bugraoz93 bugraoz93 approved these changes

romsharon98 romsharon98 approved these changes

amoghrajesh amoghrajesh approved these changes

jason810496 jason810496 approved these changes

dstandish Awaiting requested review from dstandish dstandish is a code owner

jedcunningham Awaiting requested review from jedcunningham jedcunningham is a code owner

hussein-awala Awaiting requested review from hussein-awala hussein-awala is a code owner

ashb Awaiting requested review from ashb

kaxil Awaiting requested review from kaxil

ephraimbuddy Awaiting requested review from ephraimbuddy

bolkedebruin Awaiting requested review from bolkedebruin

eladkal Awaiting requested review from eladkal

pierrejeambrun Awaiting requested review from pierrejeambrun

potiuk Awaiting requested review from potiuk

gopidesupavan Awaiting requested review from gopidesupavan

Fokko Awaiting requested review from Fokko

mik-laj Awaiting requested review from mik-laj

mobuchowski Awaiting requested review from mobuchowski

vincbeck Awaiting requested review from vincbeck

jscheffl Awaiting requested review from jscheffl jscheffl is a code owner

josh-fell Awaiting requested review from josh-fell

o-nikolas Awaiting requested review from o-nikolas

uranusjr Awaiting requested review from uranusjr

shahar1 Awaiting requested review from shahar1

bbovenzi Awaiting requested review from bbovenzi

ryanahamilton Awaiting requested review from ryanahamilton

shubhamraj-git Awaiting requested review from shubhamraj-git

rawwar Awaiting requested review from rawwar

XD-DENG Awaiting requested review from XD-DENG

Assignees

No one assigned

Labels

area:helm-chart Airflow Helm Chart

Projects

None yet

Development

Successfully merging this pull request may close these issues.

KEDA Query for multiple executors should use "executor" field instead of "queue"

6 participants