diff --git a/pkg/volume/local/local.go b/pkg/volume/local/local.go index 80a58a7374d..058d927c5ac 100644 --- a/pkg/volume/local/local.go +++ b/pkg/volume/local/local.go @@ -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) diff --git a/pkg/volume/util/operationexecutor/operation_generator.go b/pkg/volume/util/operationexecutor/operation_generator.go index a1123b8aba3..0d91d2ba2a0 100644 --- a/pkg/volume/util/operationexecutor/operation_generator.go +++ b/pkg/volume/util/operationexecutor/operation_generator.go @@ -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) diff --git a/pkg/volume/volume.go b/pkg/volume/volume.go index 1f8c37f0908..31fa8216e3e 100644 --- a/pkg/volume/volume.go +++ b/pkg/volume/volume.go @@ -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) }