From 6590c3fe35a591217e0ec808ff01b8f47f29284a Mon Sep 17 00:00:00 2001 From: Ilias Tsitsimpis Date: Thu, 15 Feb 2018 13:15:52 +0200 Subject: [PATCH] csi: Remove stale volume path The CSI mounter creates the following paths during SetUp(): * .../pods//volumes/kubernetes.io~csi//mount/ * .../pods//volumes/kubernetes.io~csi//volume_data.json During TearDown(), it does not remove the `.../kubernetes.io~csi//` directory, leaving behind orphan volumes: method cleanupOrphanedPodDirs() complains with 'Orphaned pod found, but volume paths are still present on disk'. Fix that by removing the above directory in removeMountDir(). Signed-off-by: Ilias Tsitsimpis --- pkg/volume/csi/csi_mounter.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/volume/csi/csi_mounter.go b/pkg/volume/csi/csi_mounter.go index 693a011f79..fcbe7e24ef 100644 --- a/pkg/volume/csi/csi_mounter.go +++ b/pkg/volume/csi/csi_mounter.go @@ -397,12 +397,19 @@ func removeMountDir(plug *csiPlugin, mountPath string) error { return err } // remove volume data file as well - dataFile := path.Join(path.Dir(mountPath), volDataFileName) + volPath := path.Dir(mountPath) + dataFile := path.Join(volPath, volDataFileName) glog.V(4).Info(log("also deleting volume info data file [%s]", dataFile)) if err := os.Remove(dataFile); err != nil && !os.IsNotExist(err) { glog.Error(log("failed to delete volume data file [%s]: %v", dataFile, err)) return err } + // remove volume path + glog.V(4).Info(log("deleting volume path [%s]", volPath)) + if err := os.Remove(volPath); err != nil && !os.IsNotExist(err) { + glog.Error(log("failed to delete volume path [%s]: %v", volPath, err)) + return err + } } return nil }