danhuawang commented on code in PR #14941:
URL: https://github.com/apache/gravitino/pull/14941#discussion_r4548656742
##########
dev/charts/gravitino/templates/deployment.yaml:
##########
@@ -125,15 +125,18 @@ 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" }}
- 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 32c3ae5226. The init container now sets `PGPORT` and
`PGSSLMODE` (libpq env vars used by all `psql` calls in the script). Port
defaults to `5432` or the port in `entity.jdbcUrl`; `sslmode` is parsed from
the JDBC query string. Operators can override with `postgresql.init.port` and
`postgresql.init.sslMode`. Host still uses `-h`; port/SSL no longer depend on
JDBC URL side effects only.
##########
dev/charts/gravitino/templates/_helpers.tpl:
##########
@@ -108,7 +108,97 @@ 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.
+*/}}
+{{- define "gravitino.postgresqlSchemaInitEnabled" -}}
+{{- if or .Values.postgresql.enabled (eq (include
"gravitino.entityUsesExternalPostgresql" . | trim) "true") -}}
+true
+{{- end -}}
+{{- end -}}
+
+{{/*
+Hostname for init-postgresql psql (-h).
+*/}}
+{{- define "gravitino.postgresqlInitHost" -}}
Review Comment:
Addressed in 32c3ae5226. External PostgreSQL schema init is now opt-in via
`postgresql.init.enabled` (default `false`), so existing installs with
`postgresql.enabled=false` and a `jdbc:postgresql:` URL behave as before (no
init container, no render failure). When `init.enabled=true`, host falls back
from `entity.jdbcUrl` if `postgresql.init.host` is empty;
`postgresql.init.existingSecret` is still required. In-chart Bitnami
(`postgresql.enabled=true`) continues to always run `init-postgresql`.
##########
dev/charts/gravitino/templates/deployment.yaml:
##########
@@ -155,29 +158,29 @@ spec:
fi
echo "Schema file: $schema_file"
echo "Upgrade file: $upgrade_file"
- if ! PGPASSWORD=$POSTGRES_PASSWORD psql -h {{ .Release.Name
}}-postgresql -U $POSTGRES_USER -d $GRAVITINO_DB -f "$upgrade_file"; then
+ if ! PGPASSWORD=$POSTGRES_PASSWORD psql -h {{ $pgInitHost }} -U
$POSTGRES_USER -d $GRAVITINO_DB -f "$upgrade_file"; then
echo "WARNING: Upgrade script failed: $upgrade_file" >&2
echo "Continuing with schema script..." >&2
fi
- PGPASSWORD=$POSTGRES_PASSWORD psql -h {{ .Release.Name
}}-postgresql -U $POSTGRES_USER -d $GRAVITINO_DB -f "$schema_file"
+ PGPASSWORD=$POSTGRES_PASSWORD psql -h {{ $pgInitHost }} -U
$POSTGRES_USER -d $GRAVITINO_DB -f "$schema_file"
Review Comment:
Good point — not changed in this PR. Per-pod schema init via Deployment
initContainers is the same model as in-chart PostgreSQL today; for
operator-managed external databases we are treating that as follow-up, aligned
with [#9013](https://github.com/apache/gravitino/issues/9013) (Helm hook Job +
enable flag) rather than expanding initContainer semantics here. With
`postgresql.init.enabled` defaulting to `false` for external PG, we avoid
turning that on until #9013 or an explicit operator choice. Happy to revisit
once the Job design lands.
--
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]