Fix device uncertain errors on reboot

This commit is contained in:
Hemant Kumar 2023-12-05 15:49:51 -05:00
parent 89dfbebe2e
commit ed0facacfa
4 changed files with 19 additions and 0 deletions

View File

@ -414,6 +414,10 @@ func (asw *actualStateOfWorld) IsVolumeReconstructed(volumeName v1.UniqueVolumeN
if !ok {
return false
}
if podName == operationexecutor.EmptyUniquePodName {
return true
}
_, foundPod := podMap[podName]
return foundPod
}
@ -810,6 +814,7 @@ func (asw *actualStateOfWorld) SetDeviceMountState(
volumeObj.seLinuxMountContext = &seLinuxMountContext
}
}
asw.attachedVolumes[volumeName] = volumeObj
return nil
}

View File

@ -281,6 +281,10 @@ func TestReconstructVolumesMount(t *testing.T) {
volumePath: filepath.Join("pod1uid", "volumes", "fake-plugin", volumetesting.FailOnSetupVolumeName),
expectMount: false,
},
{
name: "reconstructed volume device map fails",
volumePath: filepath.Join("pod1uid", "volumeDevices", "fake-plugin", volumetesting.FailOnSetupVolumeName),
},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {

View File

@ -39,6 +39,11 @@ import (
volumetypes "k8s.io/kubernetes/pkg/volume/util/types"
)
const (
// EmptyUniquePodName is a UniquePodName for empty string.
EmptyUniquePodName volumetypes.UniquePodName = volumetypes.UniquePodName("")
)
// OperationExecutor defines a set of operations for attaching, detaching,
// mounting, or unmounting a volume that are executed with a NewNestedPendingOperations which
// prevents more than one operation from being triggered on the same volume.

View File

@ -780,6 +780,11 @@ func (og *operationGenerator) checkForFailedMount(volumeToMount VolumeToMount, m
func (og *operationGenerator) markDeviceErrorState(volumeToMount VolumeToMount, devicePath, deviceMountPath string, mountError error, actualStateOfWorld ActualStateOfWorldMounterUpdater) {
if volumetypes.IsOperationFinishedError(mountError) &&
actualStateOfWorld.GetDeviceMountState(volumeToMount.VolumeName) == DeviceMountUncertain {
if actualStateOfWorld.IsVolumeReconstructed(volumeToMount.VolumeName, EmptyUniquePodName) {
klog.V(2).InfoS("MountVolume.markDeviceErrorState uncertainDeviceFix leaving volume uncertain", "volumeName", volumeToMount.VolumeName)
return
}
// Only devices which were uncertain can be marked as unmounted
markDeviceUnmountError := actualStateOfWorld.MarkDeviceAsUnmounted(volumeToMount.VolumeName)
if markDeviceUnmountError != nil {