WIP: Handle failed attach operation leave uncertain volume attach state
This PR fixes issue #32727. When an attach operation fails, it is still possible that the volume will be attached to the node later. This PR adds the logic to record the volume to node with attached state no matter whether the operation succedded or not. If the operation fails, mark the attached state to false. If the operation succeeded, mark the attached state to true. The reconciler will still issue attach operation until it returns successfully. If the pod is removed in the mean time, the reconciler will issue detach operations for all the volumes no matter what is the attached state.
This commit is contained in:
@@ -192,6 +192,8 @@ type ActualStateOfWorldAttacherUpdater interface {
|
||||
// volumes. See issue 29695.
|
||||
MarkVolumeAsAttached(volumeName v1.UniqueVolumeName, volumeSpec *volume.Spec, nodeName types.NodeName, devicePath string) error
|
||||
|
||||
MarkVolumeAsUncertain(volumeName v1.UniqueVolumeName, volumeSpec *volume.Spec, nodeName types.NodeName) error
|
||||
|
||||
// Marks the specified volume as detached from the specified node
|
||||
MarkVolumeAsDetached(volumeName v1.UniqueVolumeName, nodeName types.NodeName)
|
||||
|
||||
|
@@ -323,6 +323,12 @@ func (og *operationGenerator) GenerateAttachVolumeFunc(
|
||||
}
|
||||
|
||||
}
|
||||
addVolumeNodeErr := actualStateOfWorld.MarkVolumeAsUncertain(
|
||||
v1.UniqueVolumeName(""), volumeToAttach.VolumeSpec, volumeToAttach.NodeName)
|
||||
if addVolumeNodeErr != nil {
|
||||
// On failure, return error. Caller will log and retry.
|
||||
return volumeToAttach.GenerateError("AttachVolume.MarkVolumeAsUncertain failed", addVolumeNodeErr)
|
||||
}
|
||||
// On failure, return error. Caller will log and retry.
|
||||
return volumeToAttach.GenerateError("AttachVolume.Attach failed", attachErr)
|
||||
}
|
||||
|
Reference in New Issue
Block a user