Fix Gerrit-slave initialization without test mode In change 207458 the Gerrit site was moved into an emptyDir volume, which is empty at pod startup. This caused the startup of the Gerrit slave to fail, when not run in test mode, because it was not initialized before startup. This change adds a initContainer initializing the site in the emptyDir, if the test mode is disabled. Change-Id: I5339dbf37e693700292d29b354ee35c747f34109
diff --git a/helm-charts/gerrit-slave/templates/gerrit-slave.deployment.yaml b/helm-charts/gerrit-slave/templates/gerrit-slave.deployment.yaml index 4020022..8faf76c 100644 --- a/helm-charts/gerrit-slave/templates/gerrit-slave.deployment.yaml +++ b/helm-charts/gerrit-slave/templates/gerrit-slave.deployment.yaml
@@ -24,6 +24,31 @@ - name: {{ .Values.images.registry.ImagePullSecret.name }} {{- end }} initContainers: + {{ if not .Values.gerritSlave.initializeTestSite.enabled -}} + # Initialize the emptyDir containing the whole Gerrit-site with defaults + # Not needed, when running in test mode, since then the configured site will + # be initialized + - name: populate-gerrit-site-volume + image: {{ template "registry" . }}{{ .Values.gerritSlave.images.gerritInit }}:{{ .Values.images.version }} + imagePullPolicy: {{ .Values.images.imagePullPolicy }} + command: + - /bin/bash + - -ce + args: + - | + if [ ! -f /var/gerrit/bin/gerrit.sh ]; then + java -jar /var/war/gerrit.war init \ + --batch \ + --no-auto-start \ + --install-plugin singleusergroup \ + -d /var/gerrit + fi + volumeMounts: + - name: gerrit-site + mountPath: "/var/gerrit" + - name: gerrit-db + mountPath: "/var/gerrit/db" + {{- end }} - name: gerrit-init image: {{ template "registry" . }}{{ .Values.gerritSlave.images.gerritInit }}:{{ .Values.images.version }} imagePullPolicy: {{ .Values.images.imagePullPolicy }}