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:
Masaki Kimura 2019-11-12 19:44:36 +00:00
parent f363a03f0b
commit a275026ad4
3 changed files with 15 additions and 3 deletions

View File

@ -619,7 +619,7 @@ func (m *localVolumeMapper) SetUpDevice() error {
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) {
globalPath := util.MakeAbsolutePath(runtime.GOOS, m.globalPath)
klog.V(4).Infof("MapPodDevice returning path %s", globalPath)

View File

@ -1065,8 +1065,9 @@ func (og *operationGenerator) GenerateMapVolumeFunc(
}
// Update actual state of world to reflect volume is globally mounted
markedDevicePath := devicePath
markDeviceMappedErr := actualStateOfWorld.MarkDeviceAsMounted(
volumeToMount.VolumeName, devicePath, globalMapPath)
volumeToMount.VolumeName, markedDevicePath, globalMapPath)
if markDeviceMappedErr != nil {
// On failure, return error. Caller will log and retry.
return volumeToMount.GenerateError("MapVolume.MarkDeviceAsMounted failed", markDeviceMappedErr)
@ -1105,6 +1106,17 @@ func (og *operationGenerator) GenerateMapVolumeFunc(
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
volumeMapPath, volName := blockVolumeMapper.GetPodDeviceMapPath()
mapErr := ioutil.MapBlockVolume(og.blkUtil, devicePath, globalMapPath, volumeMapPath, volName, volumeToMount.Pod.UID)

View File

@ -170,7 +170,7 @@ type CustomBlockVolumeMapper interface {
// Unique device path across kubelet node reboot is required to avoid
// unexpected block volume destruction.
// 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)
}