Commit 564016bd authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #38443 from NickrenREN/vol-mgr-getVolumeInUse

Automatic merge from submit-queue (batch tested with PRs 38443, 40145, 40701, 40682) fix GetVolumeInUse() function Since we just want to get volume name info, each volume name just need to added once. desiredStateOfWorld.GetVolumesToMount() will return volume and pod binding info, if one volume is mounted to several pods, the volume name will be return several times. That is not what we want in this function. We can add a new function to only get the volume name info or judge whether the volume name is added to the desiredVolumesMap array.
parents f17010f5 3bb75064
...@@ -299,10 +299,12 @@ func (vm *volumeManager) GetVolumesInUse() []v1.UniqueVolumeName { ...@@ -299,10 +299,12 @@ func (vm *volumeManager) GetVolumesInUse() []v1.UniqueVolumeName {
for _, volume := range desiredVolumes { for _, volume := range desiredVolumes {
if volume.PluginIsAttachable { if volume.PluginIsAttachable {
if _, exists := desiredVolumesMap[volume.VolumeName]; !exists {
desiredVolumesMap[volume.VolumeName] = true desiredVolumesMap[volume.VolumeName] = true
volumesToReportInUse = append(volumesToReportInUse, volume.VolumeName) volumesToReportInUse = append(volumesToReportInUse, volume.VolumeName)
} }
} }
}
for _, volume := range mountedVolumes { for _, volume := range mountedVolumes {
if volume.PluginIsAttachable { if volume.PluginIsAttachable {
......
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