Use symlinks to bring volume mounts into site
Mounted volumes containing parts of the Gerrit site were mounted on
top of the empty site containing the rest of the Gerrit site.
This could potentially lead to issues, if the order of mounting the
volumes was incorrect.
This change uses symlinks instead. The volumes are mounted to
a different location in the container (var/mnt/$dir) and then symlinked
to the gerrit site.
Change-Id: If03bf2e19f772ec95184a0d09b510c8aefced1b6
diff --git a/helm-charts/gerrit-master/templates/gerrit-master.deployment.yaml b/helm-charts/gerrit-master/templates/gerrit-master.deployment.yaml
index 7a18558..01243b7 100644
--- a/helm-charts/gerrit-master/templates/gerrit-master.deployment.yaml
+++ b/helm-charts/gerrit-master/templates/gerrit-master.deployment.yaml
@@ -38,6 +38,9 @@
- -c
args:
- |
+ # Remove directories that should be mounted rather than exist with the
+ # rest of the site
+ [ ! -L /var/gerrit/git ] && rm -rf /var/gerrit/git
rm -f /var/gerrit/logs/gerrit.pid
volumeMounts:
- name: gerrit-site
@@ -52,7 +55,7 @@
- |
symlink_config_to_site(){
{{ if .Values.gerritMaster.keystore -}}
- ln -s /var/keystore /var/gerrit/etc/keystore
+ ln -s /var/config/keystore /var/gerrit/etc/keystore
{{- end }}
ln -sf /var/config/gerrit.config /var/gerrit/etc/gerrit.config
ln -sf /var/config/secure.config /var/gerrit/etc/secure.config
@@ -61,6 +64,10 @@
mkdir -p /var/gerrit/etc
symlink_config_to_site
+ if [ ! -d /var/gerrit/git ]; then
+ ln -sf /var/mnt/git /var/gerrit/
+ fi
+
/var/tools/gerrit_init.py \
{{- if .Values.gerritMaster.reviewdb.enabled }}
--reviewdb \
@@ -78,7 +85,7 @@
- name: gerrit-site
mountPath: "/var/gerrit"
- name: git-filesystem
- mountPath: "/var/gerrit/git"
+ mountPath: "/var/mnt/git"
- name: gerrit-config
mountPath: "/var/config/gerrit.config"
subPath: gerrit.config
@@ -87,7 +94,7 @@
subPath: secure.config
{{ if .Values.gerritMaster.keystore -}}
- name: gerrit-master-secure-config
- mountPath: "/var/keystore"
+ mountPath: "/var/config/keystore"
subPath: keystore
{{- end }}
containers:
@@ -101,7 +108,7 @@
- name: gerrit-site
mountPath: "/var/gerrit"
- name: git-filesystem
- mountPath: "/var/gerrit/git"
+ mountPath: "/var/mnt/git"
- name: gerrit-config
mountPath: "/var/config/gerrit.config"
subPath: gerrit.config
diff --git a/helm-charts/gerrit-slave/templates/gerrit-slave.deployment.yaml b/helm-charts/gerrit-slave/templates/gerrit-slave.deployment.yaml
index 03bb99f..759ef2a 100644
--- a/helm-charts/gerrit-slave/templates/gerrit-slave.deployment.yaml
+++ b/helm-charts/gerrit-slave/templates/gerrit-slave.deployment.yaml
@@ -38,6 +38,9 @@
- -c
args:
- |
+ # Remove directories that should be mounted rather than exist with the
+ # rest of the site
+ [ ! -L /var/gerrit/git ] && rm -rf /var/gerrit/git
rm -f /var/gerrit/logs/gerrit.pid
volumeMounts:
- name: gerrit-site
@@ -73,7 +76,7 @@
- |
symlink_config_to_site(){
{{ if .Values.gerritSlave.keystore -}}
- ln -s /var/keystore /var/gerrit/etc/keystore
+ ln -s /var/config/keystore /var/gerrit/etc/keystore
{{- end }}
ln -sf /var/config/gerrit.config /var/gerrit/etc/gerrit.config
ln -sf /var/config/secure.config /var/gerrit/etc/secure.config
@@ -82,6 +85,10 @@
mkdir -p /var/gerrit/etc
symlink_config_to_site
+ if [ ! -d /var/gerrit/git ]; then
+ ln -sf /var/mnt/git /var/gerrit/
+ fi
+
{{ if .Values.gerritSlave.initializeTestSite.enabled -}}
/var/tools/gerrit_init.py \
-s /var/gerrit \
@@ -95,7 +102,7 @@
- name: gerrit-site
mountPath: "/var/gerrit"
- name: git-filesystem
- mountPath: "/var/gerrit/git"
+ mountPath: "/var/mnt/git"
- name: gerrit-config
mountPath: "/var/config/gerrit.config"
subPath: gerrit.config
@@ -104,7 +111,7 @@
subPath: secure.config
{{ if .Values.gerritSlave.keystore -}}
- name: gerrit-slave-secure-config
- mountPath: "/var/keystore"
+ mountPath: "/var/config/keystore"
subPath: keystore
{{- end }}
containers:
@@ -117,7 +124,7 @@
- name: gerrit-site
mountPath: "/var/gerrit"
- name: git-filesystem
- mountPath: "/var/gerrit/git"
+ mountPath: "/var/mnt/git"
- name: gerrit-config
mountPath: "/var/config/gerrit.config"
subPath: gerrit.config
@@ -126,7 +133,7 @@
subPath: secure.config
{{ if .Values.gerritSlave.keystore -}}
- name: gerrit-slave-secure-config
- mountPath: "/var/keystore"
+ mountPath: "/var/config/keystore"
subPath: keystore
{{- end }}
resources: