mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-07 03:03:59 +00:00
Fix device uncertain errors on reboot
This commit is contained in:
parent
89dfbebe2e
commit
ed0facacfa
@ -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
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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.
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user