mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-10 12:32:03 +00:00
Use a separate function for checking if device was reconstructed
This commit is contained in:
parent
56dd5ab10f
commit
e706b6ba14
@ -404,7 +404,7 @@ func (asw *actualStateOfWorld) IsVolumeReconstructed(volumeName v1.UniqueVolumeN
|
|||||||
volumeState := asw.GetVolumeMountState(volumeName, podName)
|
volumeState := asw.GetVolumeMountState(volumeName, podName)
|
||||||
|
|
||||||
// only uncertain volumes are reconstructed
|
// only uncertain volumes are reconstructed
|
||||||
if volumeState != operationexecutor.VolumeMountUncertain && podName != operationexecutor.EmptyUniquePodName {
|
if volumeState != operationexecutor.VolumeMountUncertain {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -414,14 +414,17 @@ func (asw *actualStateOfWorld) IsVolumeReconstructed(volumeName v1.UniqueVolumeN
|
|||||||
if !ok {
|
if !ok {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if podName == operationexecutor.EmptyUniquePodName {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
_, foundPod := podMap[podName]
|
_, foundPod := podMap[podName]
|
||||||
return foundPod
|
return foundPod
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (asw *actualStateOfWorld) IsVolumeDeviceReconstructed(volumeName v1.UniqueVolumeName) bool {
|
||||||
|
asw.RLock()
|
||||||
|
defer asw.RUnlock()
|
||||||
|
_, ok := asw.foundDuringReconstruction[volumeName]
|
||||||
|
return ok
|
||||||
|
}
|
||||||
|
|
||||||
func (asw *actualStateOfWorld) CheckAndMarkVolumeAsUncertainViaReconstruction(opts operationexecutor.MarkVolumeOpts) (bool, error) {
|
func (asw *actualStateOfWorld) CheckAndMarkVolumeAsUncertainViaReconstruction(opts operationexecutor.MarkVolumeOpts) (bool, error) {
|
||||||
asw.Lock()
|
asw.Lock()
|
||||||
defer asw.Unlock()
|
defer asw.Unlock()
|
||||||
|
@ -39,11 +39,6 @@ import (
|
|||||||
volumetypes "k8s.io/kubernetes/pkg/volume/util/types"
|
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,
|
// OperationExecutor defines a set of operations for attaching, detaching,
|
||||||
// mounting, or unmounting a volume that are executed with a NewNestedPendingOperations which
|
// mounting, or unmounting a volume that are executed with a NewNestedPendingOperations which
|
||||||
// prevents more than one operation from being triggered on the same volume.
|
// prevents more than one operation from being triggered on the same volume.
|
||||||
@ -234,6 +229,10 @@ type ActualStateOfWorldMounterUpdater interface {
|
|||||||
// IsVolumeReconstructed returns true if volume currently added to actual state of the world
|
// IsVolumeReconstructed returns true if volume currently added to actual state of the world
|
||||||
// was found during reconstruction.
|
// was found during reconstruction.
|
||||||
IsVolumeReconstructed(volumeName v1.UniqueVolumeName, podName volumetypes.UniquePodName) bool
|
IsVolumeReconstructed(volumeName v1.UniqueVolumeName, podName volumetypes.UniquePodName) bool
|
||||||
|
|
||||||
|
// IsVolumeDeviceReconstructed returns true if volume device identified by volumeName has been
|
||||||
|
// found during reconstruction.
|
||||||
|
IsVolumeDeviceReconstructed(volumeName v1.UniqueVolumeName) bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActualStateOfWorldAttacherUpdater defines a set of operations updating the
|
// ActualStateOfWorldAttacherUpdater defines a set of operations updating the
|
||||||
|
@ -781,8 +781,8 @@ func (og *operationGenerator) markDeviceErrorState(volumeToMount VolumeToMount,
|
|||||||
if volumetypes.IsOperationFinishedError(mountError) &&
|
if volumetypes.IsOperationFinishedError(mountError) &&
|
||||||
actualStateOfWorld.GetDeviceMountState(volumeToMount.VolumeName) == DeviceMountUncertain {
|
actualStateOfWorld.GetDeviceMountState(volumeToMount.VolumeName) == DeviceMountUncertain {
|
||||||
|
|
||||||
if actualStateOfWorld.IsVolumeReconstructed(volumeToMount.VolumeName, EmptyUniquePodName) {
|
if actualStateOfWorld.IsVolumeDeviceReconstructed(volumeToMount.VolumeName) {
|
||||||
klog.V(2).InfoS("MountVolume.markDeviceErrorState uncertainDeviceFix leaving volume uncertain", "volumeName", volumeToMount.VolumeName)
|
klog.V(2).InfoS("MountVolume.markDeviceErrorState leaving volume uncertain", "volumeName", volumeToMount.VolumeName)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user