danhuawang commented on code in PR #14941:
URL: https://github.com/apache/gravitino/pull/14941#discussion_r4559126389
##########
dev/charts/gravitino/templates/deployment.yaml:
##########
@@ -125,15 +125,20 @@ spec:
- mountPath: /scripts
name: scripts-emptydir
{{- end }}
- {{- if .Values.postgresql.enabled }}
+ {{- if eq (include "gravitino.postgresqlSchemaInitEnabled" . | trim)
"true" }}
+ {{- $pgInitHost := include "gravitino.postgresqlInitHost" . | trim }}
+ {{- $pgInitSecret := include "gravitino.postgresqlInitSecretName" . |
trim }}
+ {{- $pgInitSecretKey :=
.Values.postgresql.init.existingSecretPasswordKey | default "password" }}
+ {{- $pgInitPort := include "gravitino.postgresqlInitPort" . | trim }}
+ {{- $pgInitSslMode := include "gravitino.postgresqlInitSslMode" . |
trim }}
- name: init-postgresql
image: {{ include "init-postgresql.image" . }}
imagePullPolicy: "{{ .Values.image.pullPolicy }}"
command:
- /bin/bash
- -c
- |
- while ! PGPASSWORD=$POSTGRES_PASSWORD psql -h {{ .Release.Name
}}-postgresql -U $POSTGRES_USER -c "SELECT 1"; do
+ while ! PGPASSWORD=$POSTGRES_PASSWORD psql -h {{ $pgInitHost }}
-U $POSTGRES_USER -c "SELECT 1"; do
Review Comment:
Addressed in 13a5e9aef6. The readiness wait now uses `-d $GRAVITINO_DB`,
matching the later schema/upgrade `psql` calls, so the probe no longer connects
to a database named after the user.
##########
dev/charts/gravitino/templates/_helpers.tpl:
##########
@@ -108,7 +108,180 @@ Return the proper MySQL image name for the init-mysql
initContainer
Return the proper Postgresql image name for the init-postgresql initContainer
*/}}
{{- define "init-postgresql.image" -}}
+{{- include "gravitino.imageReference" (dict "imageRoot"
.Values.postgresql.image "global" .Values.global) -}}
+{{- end -}}
+
+{{/*
+True when the entity store uses an external PostgreSQL JDBC URL (not in-chart
Bitnami).
+*/}}
+{{- define "gravitino.entityUsesExternalPostgresql" -}}
+{{- $url := .Values.entity.jdbcUrl | default "" -}}
+{{- if and (not .Values.mysql.enabled) (not .Values.postgresql.enabled)
(hasPrefix "jdbc:postgresql:" $url) -}}
+true
+{{- end -}}
+{{- end -}}
+
+{{/*
+True when the init-postgresql schema init container should be rendered.
+In-chart Bitnami PostgreSQL always runs schema init. External PostgreSQL runs
+only when postgresql.init.enabled is true (opt-in; see issue #9013 for hook
Job).
+*/}}
+{{- define "gravitino.postgresqlSchemaInitEnabled" -}}
{{- if .Values.postgresql.enabled -}}
- {{- include "gravitino.imageReference" (dict "imageRoot"
.Values.postgresql.image "global" .Values.global) -}}
+true
+{{- else if and (eq (include "gravitino.entityUsesExternalPostgresql" . |
trim) "true") .Values.postgresql.init.enabled -}}
+true
+{{- end -}}
+{{- end -}}
+
+{{/*
+Authority segment (host[:port]) from entity.jdbcUrl for PostgreSQL.
+*/}}
+{{- define "gravitino.entityJdbcAuthorityFromUrl" -}}
+{{- $url := .Values.entity.jdbcUrl | default "" -}}
+{{- if hasPrefix "jdbc:postgresql://" $url -}}
+{{- $path := trimPrefix "jdbc:postgresql://" $url -}}
+{{- (splitList "/" $path | first) -}}
+{{- end -}}
+{{- end -}}
+
+{{/*
+Hostname from entity.jdbcUrl authority (external PostgreSQL).
+*/}}
+{{- define "gravitino.entityJdbcHostFromUrl" -}}
+{{- $auth := include "gravitino.entityJdbcAuthorityFromUrl" . | trim -}}
+{{- if $auth -}}
+{{- if contains ":" $auth -}}
+{{- $parts := splitList ":" $auth -}}
Review Comment:
Addressed in 13a5e9aef6 by documenting the limitation rather than expanding
the parser. JDBC URL host/port fallback supports only a single `host` or
`host:port` (IPv4 / DNS). IPv6 bracket literals and multi-host authorities are
not parsed; operators should set `postgresql.init.host` and
`postgresql.init.port` for those forms. Documented in the helper comments,
`values.yaml`, and NOTES.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]