mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Merge pull request #59914 from iliastsi/feature-csi-stale-path
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. csi: Remove stale volume path **What this PR does / why we need it**: 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(). **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: **Special notes for your reviewer**: **Release note**: ```release-note NONE ```
This commit is contained in:
commit
11ecad2629
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user