mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-26 21:17:23 +00:00
Split CustomBlockVolumeMapper and CustomBlockVolumeUnmapper
- Move SetUpDevice to BlockVolumeStager - Move MapPodDevice to BlockVolumePublisher - Move TearDownDevice to BlockVolumeUnstager - Move UnmapPodDevice to BlockVolumeUnpublisher - Implement BlockVolumePublisher only in local and csi plugin - Implement BlockVolumeUnstager only in fc, iscsi, rbd, and csi plugin - Implement BlockVolumeStager and BlockVolumeUnpublisher only in csi plugin
This commit is contained in:
parent
f363a03f0b
commit
a275026ad4
@ -619,7 +619,7 @@ func (m *localVolumeMapper) SetUpDevice() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetUpDevice provides physical device path for the local PV.
|
// MapPodDevice provides physical device path for the local PV.
|
||||||
func (m *localVolumeMapper) MapPodDevice() (string, error) {
|
func (m *localVolumeMapper) MapPodDevice() (string, error) {
|
||||||
globalPath := util.MakeAbsolutePath(runtime.GOOS, m.globalPath)
|
globalPath := util.MakeAbsolutePath(runtime.GOOS, m.globalPath)
|
||||||
klog.V(4).Infof("MapPodDevice returning path %s", globalPath)
|
klog.V(4).Infof("MapPodDevice returning path %s", globalPath)
|
||||||
|
@ -1065,8 +1065,9 @@ func (og *operationGenerator) GenerateMapVolumeFunc(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update actual state of world to reflect volume is globally mounted
|
// Update actual state of world to reflect volume is globally mounted
|
||||||
|
markedDevicePath := devicePath
|
||||||
markDeviceMappedErr := actualStateOfWorld.MarkDeviceAsMounted(
|
markDeviceMappedErr := actualStateOfWorld.MarkDeviceAsMounted(
|
||||||
volumeToMount.VolumeName, devicePath, globalMapPath)
|
volumeToMount.VolumeName, markedDevicePath, globalMapPath)
|
||||||
if markDeviceMappedErr != nil {
|
if markDeviceMappedErr != nil {
|
||||||
// On failure, return error. Caller will log and retry.
|
// On failure, return error. Caller will log and retry.
|
||||||
return volumeToMount.GenerateError("MapVolume.MarkDeviceAsMounted failed", markDeviceMappedErr)
|
return volumeToMount.GenerateError("MapVolume.MarkDeviceAsMounted failed", markDeviceMappedErr)
|
||||||
@ -1105,6 +1106,17 @@ func (og *operationGenerator) GenerateMapVolumeFunc(
|
|||||||
return volumeToMount.GenerateError("MapVolume.EvalHostSymlinks failed", err)
|
return volumeToMount.GenerateError("MapVolume.EvalHostSymlinks failed", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update actual state of world with the devicePath again, if devicePath has changed from markedDevicePath
|
||||||
|
// TODO: This can be improved after #82492 is merged and ASW has state.
|
||||||
|
if markedDevicePath != devicePath {
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Execute common map
|
// Execute common map
|
||||||
volumeMapPath, volName := blockVolumeMapper.GetPodDeviceMapPath()
|
volumeMapPath, volName := blockVolumeMapper.GetPodDeviceMapPath()
|
||||||
mapErr := ioutil.MapBlockVolume(og.blkUtil, devicePath, globalMapPath, volumeMapPath, volName, volumeToMount.Pod.UID)
|
mapErr := ioutil.MapBlockVolume(og.blkUtil, devicePath, globalMapPath, volumeMapPath, volName, volumeToMount.Pod.UID)
|
||||||
|
@ -170,7 +170,7 @@ type CustomBlockVolumeMapper interface {
|
|||||||
// Unique device path across kubelet node reboot is required to avoid
|
// Unique device path across kubelet node reboot is required to avoid
|
||||||
// unexpected block volume destruction.
|
// unexpected block volume destruction.
|
||||||
// If empty string is returned, the path retuned by attacher.Attach() and
|
// If empty string is returned, the path retuned by attacher.Attach() and
|
||||||
// attacher.WaitForAttach() will be sued.
|
// attacher.WaitForAttach() will be used.
|
||||||
MapPodDevice() (string, error)
|
MapPodDevice() (string, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user