From 1eb0eee3bc2bc3b6731d920e3ec601df30b35eed Mon Sep 17 00:00:00 2001 From: Nakrez Date: Thu, 4 Mar 2021 16:43:52 +0800 Subject: [PATCH] Make the chart work with a sqlite3 database (#124) There are currently 2 issues that prevent using this chart to deploy gitea with a SQLite3 database. 1) The value from *gitea.config.database.HOST* is used to set *db.servicename* when all the databases under *gitea.database.buildIn* are not enabled. This causes a type error during the template processing: `Error: UPGRADE FAILED: template: gitea/templates/gitea/init.yaml:24:20: executing "gitea/templates/gitea/init.yaml" at : error calling include: template: gitea/templates/_helpers.tpl:64:31: executing "db.servicename" at <.Values.gitea.config.database.HOST>: wrong type for value; expected string; got interface {}` 2) In *init_gitea.sh*, we use the value *db.servicename* and *db.port* to ping the database. If this database responds to ping, we proceed with the init. The problem here is that *db.port* is not set when all the databases under *gitea.database.buildIn* are disabled. In turn, this raises an error from busybox's *nc*, because no parameter is passed for *PORT*. This causes the init container to go in *CrashLoopBackOff* forever. The simple fix that is proposed in this PR is to check wether or not *.Values.gitea.config.database.DB_TYPE* is set to determine the value *db.servicename*. If *DB_TYPE* is *'sqlite3'*, leave *db.servicename* empty and use that to bypass the database ping. Co-authored-by: Baptiste Covolato Reviewed-on: https://gitea.com/gitea/helm-chart/pulls/124 Reviewed-by: Andrew Thornton Reviewed-by: lafriks Reviewed-by: luhahn Co-authored-by: Nakrez Co-committed-by: Nakrez --- templates/_helpers.tpl | 2 +- templates/gitea/init.yaml | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl index 1dae96d..b685865 100644 --- a/templates/_helpers.tpl +++ b/templates/_helpers.tpl @@ -60,7 +60,7 @@ app.kubernetes.io/instance: {{ .Release.Name }} {{- printf "%s-mysql" .Release.Name -}} {{- else if .Values.gitea.database.builtIn.mariadb.enabled -}} {{- printf "%s-mariadb" .Release.Name -}} -{{- else -}} +{{- 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 -}} diff --git a/templates/gitea/init.yaml b/templates/gitea/init.yaml index 4266de8..926c1f2 100644 --- a/templates/gitea/init.yaml +++ b/templates/gitea/init.yaml @@ -21,7 +21,9 @@ stringData: mkdir -p /data/gitea/conf cp /etc/gitea/conf/app.ini /data/gitea/conf/app.ini chmod a+rwx /data/gitea/conf/app.ini + {{- if include "db.servicename" . }} nc -v -w2 -z {{ include "db.servicename" . }} {{ include "db.port" . }} && \ + {{- end }} su git -c ' \ set -x; \ gitea migrate; \