Skip to content

Helm: Scope KEDA_DB_CONN to worker and triggerer pods#70213

Open
pranayyelugam wants to merge 3 commits into
apache:mainfrom
pranayyelugam:fix/keda-db-conn-scope
Open

Helm: Scope KEDA_DB_CONN to worker and triggerer pods#70213
pranayyelugam wants to merge 3 commits into
apache:mainfrom
pranayyelugam:fix/keda-db-conn-scope

Conversation

@pranayyelugam

Copy link
Copy Markdown

The KEDA database connection was emitted from the shared environment helper included by every component, so enabling KEDA autoscaling on workers (or the triggerer) injected the KEDA_DB_CONN secret into the scheduler, api-server, dag-processor, flower and the migration and user-creation jobs, none of which use it. Only the worker and triggerer scalers resolve this variable, so restricting to those pods.


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

  • 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, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

@boring-cyborg

boring-cyborg Bot commented Jul 22, 2026

Copy link
Copy Markdown

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide
Here are some useful points:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our prek-hooks will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example Dag that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
  • Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: dev@airflow.apache.org
    Slack: https://s.apache.org/airflow-slack

@pranayyelugam
pranayyelugam force-pushed the fix/keda-db-conn-scope branch from 8f31203 to 5c55c6f Compare July 22, 2026 06:05
Comment thread chart/templates/_helpers.yaml Outdated
Comment thread chart/templates/_helpers.yaml Outdated
Comment on lines +153 to +157
{{- $triggererKedaEnabled := and .Values.triggerer.enabled .Values.triggerer.keda.enabled }}
{{- $workersKedaNeedsDbConn := and .Values.workers.celery.keda.enabled (or (eq .Values.data.metadataConnection.protocol "mysql") (and .Values.pgbouncer.enabled (not .Values.workers.celery.keda.usePgbouncer))) }}
{{- $triggererKedaNeedsDbConn := and $triggererKedaEnabled (or (eq .Values.data.metadataConnection.protocol "mysql") (and .Values.pgbouncer.enabled (not .Values.triggerer.keda.usePgbouncer))) }}
{{- $component := .Component | default "" }}
{{- if or (and (eq $component "worker") $workersKedaNeedsDbConn) (and (eq $component "triggerer") $triggererKedaNeedsDbConn) }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think that we could simplify this by:

  1. Moving checking if keda is enabled for a particular component to the template files
  2. Passing as an additional argument here the value of .Values.triggerer.keda.usePgBouncer or .Values.workers.celery.keda.usePgBouncer

and the rest of the logic is common.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@Miretpl Good suggestion. Updated.

return jmespath.search("spec.template.spec.containers[].env[].name", doc) or []

def test_worker_keda_db_conn_not_leaked_to_other_components(self):
"""Worker KEDA_DB_CONN should render on the worker only, not on unrelated components."""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
"""Worker KEDA_DB_CONN should render on the worker only, not on unrelated components."""

Name of the test case is descriptive enough that we don't need additional comment I think.

assert "KEDA_DB_CONN" not in self._env_names(triggerer)

def test_triggerer_keda_db_conn_not_leaked_to_other_components(self):
"""Triggerer KEDA_DB_CONN should render on the triggerer only, not on the worker or others."""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
"""Triggerer KEDA_DB_CONN should render on the triggerer only, not on the worker or others."""

Same as above comment.

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.

2 participants