mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 12:43:23 +00:00
Merge pull request #60036 from mtanino/issue/60025
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>. Fix device unmap for non-attachable plugin case **What this PR does / why we need it**: This PR fixes following problem. - If plugin is non-attachable, global unmap path isn't stored in asw, then plugin fails to unmap volume. To store the path, this PR moves MarkDeviceAsMounted operation from the `if volumeAttacher != nil` block. **Which issue(s) this PR fixes**: Fixes #60025 **Special notes for your reviewer**: **Release note**: ```release-note NONE ``` /sig storage /cc @msau42 @jingxu97 @dhirajh @ianchakeres @mlmhl
This commit is contained in:
commit
d94bc9ef85
@ -837,13 +837,6 @@ func (og *operationGenerator) GenerateMapVolumeFunc(
|
|||||||
|
|
||||||
glog.Infof(volumeToMount.GenerateMsgDetailed("MapVolume.WaitForAttach succeeded", fmt.Sprintf("DevicePath %q", devicePath)))
|
glog.Infof(volumeToMount.GenerateMsgDetailed("MapVolume.WaitForAttach succeeded", fmt.Sprintf("DevicePath %q", devicePath)))
|
||||||
|
|
||||||
// Update actual state of world to reflect volume is globally mounted
|
|
||||||
markDeviceMappedErr := actualStateOfWorld.MarkDeviceAsMounted(
|
|
||||||
volumeToMount.VolumeName, devicePath, globalMapPath)
|
|
||||||
if markDeviceMappedErr != nil {
|
|
||||||
// On failure, return error. Caller will log and retry.
|
|
||||||
return volumeToMount.GenerateError("MapVolume.MarkDeviceAsMounted failed", markDeviceMappedErr)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// A plugin doesn't have attacher also needs to map device to global map path with SetUpDevice()
|
// A plugin doesn't have attacher also needs to map device to global map path with SetUpDevice()
|
||||||
pluginDevicePath, mapErr := blockVolumeMapper.SetUpDevice()
|
pluginDevicePath, mapErr := blockVolumeMapper.SetUpDevice()
|
||||||
@ -859,6 +852,13 @@ func (og *operationGenerator) GenerateMapVolumeFunc(
|
|||||||
return volumeToMount.GenerateError("MapVolume failed", fmt.Errorf("Device path of the volume is empty"))
|
return volumeToMount.GenerateError("MapVolume failed", fmt.Errorf("Device path of the volume is empty"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Update actual state of world to reflect volume is globally mounted
|
||||||
|
markDeviceMappedErr := actualStateOfWorld.MarkDeviceAsMounted(
|
||||||
|
volumeToMount.VolumeName, devicePath, globalMapPath)
|
||||||
|
if markDeviceMappedErr != nil {
|
||||||
|
// On failure, return error. Caller will log and retry.
|
||||||
|
return volumeToMount.GenerateError("MapVolume.MarkDeviceAsMounted failed", markDeviceMappedErr)
|
||||||
|
}
|
||||||
|
|
||||||
mapErr = og.blkUtil.MapDevice(devicePath, globalMapPath, string(volumeToMount.Pod.UID))
|
mapErr = og.blkUtil.MapDevice(devicePath, globalMapPath, string(volumeToMount.Pod.UID))
|
||||||
if mapErr != nil {
|
if mapErr != nil {
|
||||||
@ -961,10 +961,6 @@ func (og *operationGenerator) GenerateUnmapVolumeFunc(
|
|||||||
// Try to unmap podUID symlink under global map path dir
|
// Try to unmap podUID symlink under global map path dir
|
||||||
// plugins/kubernetes.io/{PluginName}/volumeDevices/{volumePluginDependentPath}/{podUID}
|
// plugins/kubernetes.io/{PluginName}/volumeDevices/{volumePluginDependentPath}/{podUID}
|
||||||
globalUnmapPath := volumeToUnmount.DeviceMountPath
|
globalUnmapPath := volumeToUnmount.DeviceMountPath
|
||||||
if err != nil {
|
|
||||||
// On failure, return error. Caller will log and retry.
|
|
||||||
return volumeToUnmount.GenerateError("UnmapVolume.GetGlobalUnmapPath failed", err)
|
|
||||||
}
|
|
||||||
unmapDeviceErr = og.blkUtil.UnmapDevice(globalUnmapPath, string(volumeToUnmount.PodUID))
|
unmapDeviceErr = og.blkUtil.UnmapDevice(globalUnmapPath, string(volumeToUnmount.PodUID))
|
||||||
if unmapDeviceErr != nil {
|
if unmapDeviceErr != nil {
|
||||||
// On failure, return error. Caller will log and retry.
|
// On failure, return error. Caller will log and retry.
|
||||||
@ -1034,10 +1030,6 @@ func (og *operationGenerator) GenerateUnmapDeviceFunc(
|
|||||||
// Search under globalMapPath dir if all symbolic links from pods have been removed already.
|
// Search under globalMapPath dir if all symbolic links from pods have been removed already.
|
||||||
// If symbolick links are there, pods may still refer the volume.
|
// If symbolick links are there, pods may still refer the volume.
|
||||||
globalMapPath := deviceToDetach.DeviceMountPath
|
globalMapPath := deviceToDetach.DeviceMountPath
|
||||||
if err != nil {
|
|
||||||
// On failure, return error. Caller will log and retry.
|
|
||||||
return deviceToDetach.GenerateError("UnmapDevice.GetGlobalMapPath failed", err)
|
|
||||||
}
|
|
||||||
refs, err := og.blkUtil.GetDeviceSymlinkRefs(deviceToDetach.DevicePath, globalMapPath)
|
refs, err := og.blkUtil.GetDeviceSymlinkRefs(deviceToDetach.DevicePath, globalMapPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return deviceToDetach.GenerateError("UnmapDevice.GetDeviceSymlinkRefs check failed", err)
|
return deviceToDetach.GenerateError("UnmapDevice.GetDeviceSymlinkRefs check failed", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user