Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

HsiuChuanHsu
Copy link

@HsiuChuanHsu HsiuChuanHsu commented Jul 4, 2025

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:

image

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.

@boring-cyborg boring-cyborg bot added the area:helm-chart Airflow Helm Chart label Jul 4, 2025
@eladkal eladkal requested a review from romsharon98 July 8, 2025 13:48
@romsharon98
Copy link
Contributor

Tests need to be fixed

Copy link
Member

@jason810496 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!

@eladkal eladkal added this to the Airflow Helm Chart 1.19.0 milestone Jul 11, 2025
Copy link
Contributor

@bugraoz93 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

@bugraoz93
Copy link
Contributor

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

- 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 HsiuChuanHsu force-pushed the bug/keda-query-executor-mismatch branch from b749ba9 to 15b0e67 Compare July 11, 2025 23:32
@HsiuChuanHsu
Copy link
Author

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

@bugraoz93
Copy link
Contributor

This is it, thanks! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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