From d699be710a62bb21be29062ba70c9773e62ce18a Mon Sep 17 00:00:00 2001 From: Peter Wang Date: Fri, 1 Mar 2019 13:58:30 +0800 Subject: [PATCH] Make provisioner root persistent across reboot If the proversioner container or the host restart data dir under /tmp in the container will be lost thus causing start up failure for any pods using csi pv. It's good to make the provisioner root persistent so that this plugin is more reliable for daily testing. --- deploy/hostpath/csi-hostpath-plugin.yaml | 7 +++++++ pkg/hostpath/controllerserver.go | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/deploy/hostpath/csi-hostpath-plugin.yaml b/deploy/hostpath/csi-hostpath-plugin.yaml index 1120a6858..5e26ed0a4 100644 --- a/deploy/hostpath/csi-hostpath-plugin.yaml +++ b/deploy/hostpath/csi-hostpath-plugin.yaml @@ -60,6 +60,8 @@ spec: name: socket-dir - mountPath: /registration name: registration-dir + - mountPath: /csi-data-dir + name: csi-data-dir - name: hostpath image: quay.io/k8scsi/hostpathplugin:v1.0.1 @@ -104,3 +106,8 @@ spec: path: /var/lib/kubelet/plugins type: Directory name: plugins-dir + # 'path' is where PV data is persisted on host. + # using /tmp is also possible while the PVs will not available after plugin container recreation or host reboot + path: /var/lib/csi-hostpath-data/ + type: DirectoryOrCreate + name: csi-data-dir diff --git a/pkg/hostpath/controllerserver.go b/pkg/hostpath/controllerserver.go index 5e194946d..1efcd9e99 100644 --- a/pkg/hostpath/controllerserver.go +++ b/pkg/hostpath/controllerserver.go @@ -38,8 +38,8 @@ import ( const ( deviceID = "deviceID" - provisionRoot = "/tmp/" - snapshotRoot = "/tmp/" + provisionRoot = "/csi-data-dir" + snapshotRoot = "/csi-data-dir" maxStorageCapacity = tib )