Commit 6590c3fe authored by Ilias Tsitsimpis's avatar Ilias Tsitsimpis

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: 's avatarIlias Tsitsimpis <iliastsi@arrikto.com>
parent 7377c591
......@@ -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
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment