Add terminationGracePeriodSeconds support for PgBouncer in Helm chart - #71237
Open
antruigon wants to merge 2 commits into
Open
Add terminationGracePeriodSeconds support for PgBouncer in Helm chart#71237antruigon wants to merge 2 commits into
antruigon wants to merge 2 commits into
Conversation
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 any node drain or eviction, cutting 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. Defaults to 120 to match the drain window of the default preStop hook. Since PgBouncer exits as soon as the last client connection is released, the full 120s is an upper bound, not a fixed wait. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
antruigon
requested review from
Miretpl,
bugraoz93,
hussein-awala,
jedcunningham and
jscheffl
as code owners
August 6, 2026 12:07
|
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
|
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
pgbouncer.terminationGracePeriodSecondsto the Helm chart, rendered on the PgBouncer Deployment's pod spec. Defaults to 120 to match the drain window of the chart's default preStop hook.Why
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 any node drain or eviction (cluster upgrades, autoscaler scale-down, AMI rolls) in-flight client connections are cut instead of drained — workers seepsycopg2.OperationalError: server closed the connection unexpectedly, and tasks that were mid-query fail. We hit this in production during a routine EKS node-group AMI roll: one evicted PgBouncer replica cut ~880 in-flight connections and failed 21 zero-retry DAG runs.Every other long-running component in the chart already exposes this knob (
scheduler,workers.celery,triggerer,dagProcessor,statsd,redis,otelCollector); PgBouncer was the only one missing it, and it is arguably the component that needs it most since it holds everyone's DB connections.Default choice
120, matching the shipped preStop. Note this is an upper bound, not a fixed wait: PgBouncer receives SIGINT immediately, stops accepting new connections, and exits as soon as the last client connection is released — so pods still terminate quickly under low load. Users who prefer the old behaviour can set it back to30.Changes
chart/values.yaml— newpgbouncer.terminationGracePeriodSeconds: 120next to the preStop hook it pairs withchart/values.schema.json— schema entry (integer, default 120, Kubernetes docs section)chart/templates/pgbouncer/pgbouncer-deployment.yaml— render the field on the pod specchart/tests/helm_tests/other/test_pgbouncer.py— parametrized test for default + override (mirrorstest_statsd.py)All 86 tests in
test_pgbouncer.py+test_pdb_pgbouncer.pypass locally.