danhuawang commented on code in PR #14941:
URL: https://github.com/apache/gravitino/pull/14941#discussion_r4594678637
##########
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:
Still addressed in `32c3ae5226`; no further changes in `bf4c26b16`.
Resolving.
##########
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:
Still addressed in `32c3ae5226` (opt-in `postgresql.init.enabled`).
Resolving.
##########
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:
No code change in `bf4c26b16`; stance unchanged (opt-in external init, #9013
follow-up). Resolving.
##########
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:
Still addressed in `13a5e9aef6` (`-d $GRAVITINO_DB`). Resolving.
##########
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:
Still addressed in `13a5e9aef6` (documented single host:port) and
`3315644c3c` (render fail for `[` / `,`). Resolving.
--
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]