Remove db connection check (#299)
This will remove the db connection check, which has caused some trouble in the past. It will now simply run _gitea migrate_ and output a message, if the database is not available. Co-authored-by: Lucas Hahn <lucas.hahn@novum-rgi.de> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Reviewed-on: https://gitea.com/gitea/helm-chart/pulls/299 Reviewed-by: justusbunsi <justusbunsi@noreply.gitea.io> Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: luhahn <luhahn@noreply.gitea.io> Co-committed-by: luhahn <luhahn@noreply.gitea.io>
This commit is contained in:
parent
78b5858009
commit
d35de55248
@ -61,30 +61,6 @@ app.kubernetes.io/name: {{ include "gitea.name" . }}
|
|||||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
{{- define "db.servicename" -}}
|
|
||||||
{{- if .Values.postgresql.enabled -}}
|
|
||||||
{{- printf "%s-postgresql" .Release.Name -}}
|
|
||||||
{{- else if .Values.mysql.enabled -}}
|
|
||||||
{{- printf "%s-mysql" .Release.Name -}}
|
|
||||||
{{- else if .Values.mariadb.enabled -}}
|
|
||||||
{{- printf "%s-mariadb" .Release.Name -}}
|
|
||||||
{{- else if ne .Values.gitea.config.database.DB_TYPE "sqlite3" -}}
|
|
||||||
{{- $parts := split ":" .Values.gitea.config.database.HOST -}}
|
|
||||||
{{- printf "%s %s" $parts._0 $parts._1 -}}
|
|
||||||
{{- end -}}
|
|
||||||
{{- end -}}
|
|
||||||
|
|
||||||
{{- define "db.port" -}}
|
|
||||||
{{- if .Values.postgresql.enabled -}}
|
|
||||||
{{ .Values.postgresql.global.postgresql.servicePort }}
|
|
||||||
{{- else if .Values.mysql.enabled -}}
|
|
||||||
{{ .Values.mysql.service.port }}
|
|
||||||
{{- else if .Values.mariadb.enabled -}}
|
|
||||||
{{ .Values.mariadb.primary.service.port }}
|
|
||||||
{{- else -}}
|
|
||||||
{{- end -}}
|
|
||||||
{{- end -}}
|
|
||||||
|
|
||||||
{{- define "postgresql.dns" -}}
|
{{- define "postgresql.dns" -}}
|
||||||
{{- printf "%s-postgresql.%s.svc.%s:%g" .Release.Name .Release.Namespace .Values.clusterDomain .Values.postgresql.global.postgresql.servicePort -}}
|
{{- printf "%s-postgresql.%s.svc.%s:%g" .Release.Name .Release.Namespace .Values.clusterDomain .Values.postgresql.global.postgresql.servicePort -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
@ -40,31 +40,15 @@ stringData:
|
|||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
{{- if include "db.servicename" . }}
|
|
||||||
# Connection retry inspired by https://gist.github.com/dublx/e99ea94858c07d2ca6de
|
|
||||||
function test_db_connection() {
|
|
||||||
local RETRY=0
|
|
||||||
local MAX=30
|
|
||||||
|
|
||||||
echo 'Wait for database to become avialable...'
|
|
||||||
until [ "${RETRY}" -ge "${MAX}" ]; do
|
|
||||||
nc -vz -w2 {{ include "db.servicename" . }} {{ include "db.port" . }} && break
|
|
||||||
RETRY=$[${RETRY}+1]
|
|
||||||
echo "...not ready yet (${RETRY}/${MAX})"
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ "${RETRY}" -ge "${MAX}" ]; then
|
|
||||||
echo "Database not reachable after '${MAX}' attempts!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
test_db_connection
|
|
||||||
{{- end }}
|
|
||||||
|
|
||||||
echo '==== BEGIN GITEA CONFIGURATION ===='
|
echo '==== BEGIN GITEA CONFIGURATION ===='
|
||||||
|
|
||||||
|
{ # try
|
||||||
gitea migrate
|
gitea migrate
|
||||||
|
} || { # catch
|
||||||
|
echo "Gitea migrate might fail due to database connection...This init-container will try again in a few seconds"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
{{- if or .Values.gitea.admin.existingSecret (and .Values.gitea.admin.username .Values.gitea.admin.password) }}
|
{{- if or .Values.gitea.admin.existingSecret (and .Values.gitea.admin.username .Values.gitea.admin.password) }}
|
||||||
function configure_admin_user() {
|
function configure_admin_user() {
|
||||||
|
Loading…
Reference in New Issue
Block a user