Skip to content
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

fix: pgbouncer connection with useStandardNaming #34787

Merged
merged 2 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion chart/templates/secrets/metadata-connection-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
{{- if not .Values.data.metadataSecretName }}
{{- $defaultMetadataHost := .Values.postgresql.nameOverride | default (printf "%s-%s.%s" .Release.Name "postgresql" .Release.Namespace) }}
{{- $metadataHost := .Values.data.metadataConnection.host | default $defaultMetadataHost }}
{{- $pgbouncerHost := (printf "%s-%s.%s" .Release.Name "pgbouncer" .Release.Namespace) }}
{{- $pgbouncerHost := (printf "%s-%s.%s" ( include "airflow.fullname" . ) "pgbouncer" .Release.Namespace) }}
{{- $host := ternary $pgbouncerHost $metadataHost .Values.pgbouncer.enabled }}
{{- $port := ((ternary .Values.ports.pgbouncer .Values.data.metadataConnection.port .Values.pgbouncer.enabled) | toString) }}
{{- $database := (ternary (printf "%s-%s" .Release.Name "metadata") .Values.data.metadataConnection.db .Values.pgbouncer.enabled) }}
Expand Down
26 changes: 26 additions & 0 deletions helm_tests/airflow_aux/test_basic_helm_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,32 @@
== base64.b64decode(doc["data"]["connection"]).decode("utf-8")
)

def test_postgres_connection_url_pgbouncer(self):
# no nameoverride, pgbouncer
doc = render_chart(
"my-release",
show_only=["templates/secrets/metadata-connection-secret.yaml"],
values={"pgbouncer": {"enabled": True}},
)[0]
assert "postgresql://postgres:postgres@my-release-pgbouncer.default:6543/my-release-metadata?sslmode=disable" == base64.b64decode(

Check failure on line 583 in helm_tests/airflow_aux/test_basic_helm_chart.py

View workflow job for this annotation

GitHub Actions / Static checks

Ruff (E501)

helm_tests/airflow_aux/test_basic_helm_chart.py:583:111: E501 Line too long (138 > 110 characters)
doc["data"]["connection"]
).decode(
"utf-8"
)

def test_postgres_connection_url_pgbouncer_use_standard_naming(self):
# no nameoverride, pgbouncer and useStandardNaming
doc = render_chart(
"my-release",
show_only=["templates/secrets/metadata-connection-secret.yaml"],
values={"useStandardNaming": True, "pgbouncer": {"enabled": True}},
)[0]
assert "postgresql://postgres:postgres@my-release-airflow-pgbouncer.default:6543/my-release-metadata?sslmode=disable" == base64.b64decode(

Check failure on line 596 in helm_tests/airflow_aux/test_basic_helm_chart.py

View workflow job for this annotation

GitHub Actions / Static checks

Ruff (E501)

helm_tests/airflow_aux/test_basic_helm_chart.py:596:111: E501 Line too long (146 > 110 characters)
doc["data"]["connection"]
).decode(
"utf-8"
)

def test_postgres_connection_url_name_override(self):
# nameoverride provided
doc = render_chart(
Expand Down