mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 20:53:33 +00:00
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>
This commit is contained in:
parent
7377c5911a
commit
6590c3fe35
@ -397,12 +397,19 @@ func removeMountDir(plug *csiPlugin, mountPath string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// remove volume data file as well
|
// 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))
|
glog.V(4).Info(log("also deleting volume info data file [%s]", dataFile))
|
||||||
if err := os.Remove(dataFile); err != nil && !os.IsNotExist(err) {
|
if err := os.Remove(dataFile); err != nil && !os.IsNotExist(err) {
|
||||||
glog.Error(log("failed to delete volume data file [%s]: %v", dataFile, err))
|
glog.Error(log("failed to delete volume data file [%s]: %v", dataFile, err))
|
||||||
return 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
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user