This is an automated email from the ASF dual-hosted git repository.
Miretpl pushed a commit to branch chart/v1-2x-test
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/chart/v1-2x-test by this push:
new 2c4d785865e [chart/v1-2x-test] Add terminationGracePeriodSeconds
support for PgBouncer in Helm chart (#71237) (#71787)
2c4d785865e is described below
commit 2c4d785865ec7f023caf3993336a5f085797c99e
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Tue Aug 18 22:38:30 2026 +0200
[chart/v1-2x-test] Add terminationGracePeriodSeconds support for PgBouncer
in Helm chart (#71237) (#71787)
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.
(cherry picked from commit 0815a27eae7a8c9b6f336255437d8ed344cdaf3a)
Co-authored-by: antruigon <[email protected]>
Co-authored-by: Przemysław Mirowski
<[email protected]>
---
chart/templates/pgbouncer/pgbouncer-deployment.yaml | 1 +
chart/values.schema.json | 7 +++++++
chart/values.yaml | 6 ++++++
helm-tests/tests/helm_tests/other/test_pgbouncer.py | 14 ++++++++++++++
4 files changed, 28 insertions(+)
diff --git a/chart/templates/pgbouncer/pgbouncer-deployment.yaml
b/chart/templates/pgbouncer/pgbouncer-deployment.yaml
index 45c4a714877..96f523a6d9e 100644
--- a/chart/templates/pgbouncer/pgbouncer-deployment.yaml
+++ b/chart/templates/pgbouncer/pgbouncer-deployment.yaml
@@ -87,6 +87,7 @@ spec:
{{- end }}
tolerations: {{- toYaml $tolerations | nindent 8 }}
topologySpreadConstraints: {{- toYaml $topologySpreadConstraints |
nindent 8 }}
+ terminationGracePeriodSeconds: {{
.Values.pgbouncer.terminationGracePeriodSeconds }}
serviceAccountName: {{ include "pgbouncer.serviceAccountName" . }}
{{- include "serviceLinks" . | nindent 6 }}
securityContext: {{ $securityContext | nindent 8 }}
diff --git a/chart/values.schema.json b/chart/values.schema.json
index 092e5abc2d1..f04ef036c58 100644
--- a/chart/values.schema.json
+++ b/chart/values.schema.json
@@ -10061,6 +10061,13 @@
}
]
},
+ "terminationGracePeriodSeconds": {
+ "description": "Grace period for PgBouncer to finish after
SIGTERM is sent from Kubernetes.",
+ "type": "integer",
+ "default": 120,
+ "minimum": 0,
+ "x-docsSection": "Kubernetes"
+ },
"securityContexts": {
"description": "Security context definition for the
PgBouncer.",
"type": "object",
diff --git a/chart/values.yaml b/chart/values.yaml
index 274a8d79b4a..5fcac27903e 100644
--- a/chart/values.yaml
+++ b/chart/values.yaml
@@ -3916,6 +3916,12 @@ pgbouncer:
# Allow existing queries clients to complete within 120 seconds
command: ["/bin/sh", "-c", "killall -INT pgbouncer && sleep 120"]
+ # Grace period for PgBouncer to finish after SIGTERM is sent from Kubernetes.
+ # Matches the default preStop hook above, which needs up to 120 seconds to
+ # drain client connections; with a shorter grace period the pod is killed
+ # mid-drain and in-flight connections are cut.
+ terminationGracePeriodSeconds: 120
+
metricsExporterSidecar:
resources: {}
# limits:
diff --git a/helm-tests/tests/helm_tests/other/test_pgbouncer.py
b/helm-tests/tests/helm_tests/other/test_pgbouncer.py
index 27e0f60378a..8bde2b419e8 100644
--- a/helm-tests/tests/helm_tests/other/test_pgbouncer.py
+++ b/helm-tests/tests/helm_tests/other/test_pgbouncer.py
@@ -431,6 +431,20 @@ class TestPgbouncer:
assert "labels" in jmespath.search("spec.template.metadata", docs[0])
assert jmespath.search("spec.template.metadata.labels",
docs[0])["test_label"] == "test_label_value"
+ @pytest.mark.parametrize(
+ ("pgbouncer_values", "expected"),
+ [
+ ({"enabled": True}, 120),
+ ({"enabled": True, "terminationGracePeriodSeconds": 30}, 30),
+ ],
+ )
+ def test_pgbouncer_termination_grace_period_seconds(self,
pgbouncer_values, expected):
+ docs = render_chart(
+ values={"pgbouncer": pgbouncer_values},
+ show_only=["templates/pgbouncer/pgbouncer-deployment.yaml"],
+ )
+ assert expected ==
jmespath.search("spec.template.spec.terminationGracePeriodSeconds", docs[0])
+
class TestPgbouncerConfig:
"""Tests PgBouncer config."""