csi: Remove stale volume path

The CSI mounter creates the following paths during SetUp():

   * .../pods/<podID>/volumes/kubernetes.io~csi/<specVolId>/mount/
   * .../pods/<podID>/volumes/kubernetes.io~csi/<specVolId>/volume_data.json

During TearDown(), it does not remove the `.../kubernetes.io~csi/<specVolId>/`
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 <iliastsi@arrikto.com>
pull/6/head
Ilias Tsitsimpis 2018-02-15 13:15:52 +02:00
parent 7377c5911a
commit 6590c3fe35
1 changed files with 8 additions and 1 deletions

View File

@ -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
}