Add initContainer to clean up Gerrit site Since parts of the Gerrit site are persisted through pod restarts, some remnants could keep Gerrit from restarting, e.g. the ./logs/gerrit.pid file. This change adds an initContainer dedicated to clean up the site before Gerrit starts up. At this point in time, it only removes the gerrit.pid file, if present. Change-Id: Ie10f309abf8b4a77fdbdd836d4380187ce1b849f
diff --git a/helm-charts/gerrit-master/templates/gerrit-master.deployment.yaml b/helm-charts/gerrit-master/templates/gerrit-master.deployment.yaml index 95b57c7..19dbdab 100644 --- a/helm-charts/gerrit-master/templates/gerrit-master.deployment.yaml +++ b/helm-charts/gerrit-master/templates/gerrit-master.deployment.yaml
@@ -24,6 +24,20 @@ - name: {{ .Values.images.registry.ImagePullSecret.name }} {{- end }} initContainers: + - name: site-cleanup + image: busybox + securityContext: + runAsUser: 1000 + runAsGroup: 100 + command: + - sh + - -c + args: + - | + rm -f /var/gerrit/logs/gerrit.pid + volumeMounts: + - name: gerrit-logs + mountPath: "/var/gerrit/logs" - name: gerrit-init image: {{ template "registry" . }}{{ .Values.gerritMaster.images.gerritInit }}:{{ .Values.images.version }} imagePullPolicy: {{ .Values.images.imagePullPolicy }}
diff --git a/helm-charts/gerrit-slave/templates/gerrit-slave.deployment.yaml b/helm-charts/gerrit-slave/templates/gerrit-slave.deployment.yaml index 8faf76c..c54955d 100644 --- a/helm-charts/gerrit-slave/templates/gerrit-slave.deployment.yaml +++ b/helm-charts/gerrit-slave/templates/gerrit-slave.deployment.yaml
@@ -24,6 +24,20 @@ - name: {{ .Values.images.registry.ImagePullSecret.name }} {{- end }} initContainers: + - name: site-cleanup + image: busybox + securityContext: + runAsUser: 1000 + runAsGroup: 100 + command: + - sh + - -c + args: + - | + rm -f /var/gerrit/logs/gerrit.pid + volumeMounts: + - name: gerrit-logs + mountPath: "/var/gerrit/logs" {{ 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 @@ -118,8 +132,6 @@ - -c args: - | - rm -f /var/gerrit/logs/gerrit.pid - {{ if .Values.gerritSlave.keystore -}} ln -s /var/keystore /var/gerrit/etc/keystore {{- end }}