Skip to content

Add terminationGracePeriodSeconds support for PgBouncer in Helm chart - #71237

Open
antruigon wants to merge 1 commit into
apache:mainfrom
antruigon:add-pgbouncer-termination-grace-period
Open

Add terminationGracePeriodSeconds support for PgBouncer in Helm chart#71237
antruigon wants to merge 1 commit into
apache:mainfrom
antruigon:add-pgbouncer-termination-grace-period

Conversation

@antruigon

@antruigon antruigon commented Aug 6, 2026

Copy link
Copy Markdown

The chart ships a default PgBouncer preStop hook that drains client connections for up to 120 seconds (killall -INT pgbouncer && sleep 120), but the Deployment never sets terminationGracePeriodSeconds, so the Kubernetes default of 30s SIGKILLs the pod mid-drain on a node drain or eviction and cuts in-flight client connections.

Every other long-running component in the chart (scheduler, workers, triggerer, dag-processor, statsd, redis, otel collector) already exposes this value; PgBouncer was the only one missing it, despite holding the database connections of all the others.

This adds pgbouncer.terminationGracePeriodSeconds, defaulting to 120 to match the preStop drain window. PgBouncer exits as soon as the last client connection is released, so the value is an upper bound rather than a fixed wait. Deployments that prefer the previous behaviour can set it back to 30.

Covered by a parametrized test in test_pgbouncer.py (default and override).


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Claude Fable 5)

Generated-by: Claude Code (Claude Fable 5) following the guidelines

@boring-cyborg

boring-cyborg Bot commented Aug 6, 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

Comment thread chart/newsfragments/71237.significant.rst Outdated
Comment thread chart/values.schema.json Outdated
Comment thread chart/values.schema.json
@Miretpl Miretpl added this to the Airflow Helm Chart 1.23.0 milestone Aug 13, 2026
@Miretpl Miretpl added the backport-to-chart/v1-2x-test Automatic backport to chart 1.2x maintenance branch label Aug 13, 2026
@Miretpl

Miretpl commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Could you please match the PR description with the project template and follow https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions?

The chart ships a default PgBouncer preStop hook that drains client
connections for up to 120 seconds, but the Deployment never sets
terminationGracePeriodSeconds, so the Kubernetes default of 30s SIGKILLs
the pod mid-drain on a node drain or eviction and cuts in-flight client
connections.

Every other long-running component in the chart already exposes this
value; PgBouncer was the only one missing it, despite being the
component that holds the database connections of all the others.

The default of 120 matches the drain window of the default preStop hook.
PgBouncer exits as soon as the last client connection is released, so
the value is an upper bound rather than a fixed wait.
@antruigon
antruigon force-pushed the add-pgbouncer-termination-grace-period branch from 89ef4d3 to f828912 Compare August 18, 2026 10:33
@antruigon

Copy link
Copy Markdown
Author

Done, sorry for the miss. The description now follows the project template and includes the Gen-AI disclosure. The change was AI-assisted and reviewed by me. I validated the rendered chart and ran the helm tests locally (test_pgbouncer.py, test_pdb_pgbouncer.py, test_chart_quality.py) before pushing

@antruigon
antruigon requested a review from Miretpl August 18, 2026 10:47
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 backport-to-chart/v1-2x-test Automatic backport to chart 1.2x maintenance branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants