Fix issue in node status updating VolumeAttached list
During volume detach, the following might happen in reconciler 1. Pod is deleting 2. remove volume from reportedAsAttached, so node status updater will update volumeAttached list 3. detach failed due to some issue 4. volume is added back in reportedAsAttached 5. reconciler loops again the volume, remove volume from reportedAsAttached 6. detach will not be trigged because exponential back off, detach call will fail with exponential backoff error 7. another pod is added which using the same volume on the same node 8. reconciler loops and it will NOT try to tigger detach anymore At this point, volume is still attached and in actual state, but volumeAttached list in node status does not has this volume anymore, and will block volume mount from kubelet. The fix in first round is to add volume back into the volume list that need to reported as attached at step 6 when detach call failed with error (exponentical backoff). However this might has some performance issue if detach fail for a while. During this time, volume will be keep removing/adding back to node status which will cause a surge of API calls. So we changed to logic to check first whether operation is safe to retry which means no pending operation or it is not in exponentical backoff time period before calling detach. This way we can avoid keep removing/adding volume from node status. Change-Id: I5d4e760c880d72937d34b9d3e904ecad125f802e
This commit is contained in:
@@ -141,6 +141,9 @@ type OperationExecutor interface {
|
||||
// IsOperationPending returns true if an operation for the given volumeName
|
||||
// and one of podName or nodeName is pending, otherwise it returns false
|
||||
IsOperationPending(volumeName v1.UniqueVolumeName, podName volumetypes.UniquePodName, nodeName types.NodeName) bool
|
||||
// IsOperationSafeToRetry returns false if an operation for the given volumeName
|
||||
// and one of podName or nodeName is pending or in exponential backoff, otherwise it returns true
|
||||
IsOperationSafeToRetry(volumeName v1.UniqueVolumeName, podName volumetypes.UniquePodName, nodeName types.NodeName, operationName string) bool
|
||||
// ExpandInUseVolume will resize volume's file system to expected size without unmounting the volume.
|
||||
ExpandInUseVolume(volumeToMount VolumeToMount, actualStateOfWorld ActualStateOfWorldMounterUpdater) error
|
||||
// ReconstructVolumeOperation construct a new volumeSpec and returns it created by plugin
|
||||
@@ -664,6 +667,14 @@ func (oe *operationExecutor) IsOperationPending(
|
||||
return oe.pendingOperations.IsOperationPending(volumeName, podName, nodeName)
|
||||
}
|
||||
|
||||
func (oe *operationExecutor) IsOperationSafeToRetry(
|
||||
volumeName v1.UniqueVolumeName,
|
||||
podName volumetypes.UniquePodName,
|
||||
nodeName types.NodeName,
|
||||
operationName string) bool {
|
||||
return oe.pendingOperations.IsOperationSafeToRetry(volumeName, podName, nodeName, operationName)
|
||||
}
|
||||
|
||||
func (oe *operationExecutor) AttachVolume(
|
||||
volumeToAttach VolumeToAttach,
|
||||
actualStateOfWorld ActualStateOfWorldAttacherUpdater) error {
|
||||
|
Reference in New Issue
Block a user