nestedpendingoperations

package
v1.26.0-beta.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2022 License: Apache-2.0 Imports: 8 Imported by: 64

Documentation

Overview

Package nestedpendingoperations is a modified implementation of pkg/util/goroutinemap. It implements a data structure for managing go routines by volume/pod name. It prevents the creation of new go routines if an existing go routine for the volume already exists. It also allows multiple operations to execute in parallel for the same volume as long as they are operating on different pods.

Index

Constants

View Source
const (
	// EmptyUniquePodName is a UniquePodName for empty string.
	EmptyUniquePodName volumetypes.UniquePodName = volumetypes.UniquePodName("")

	// EmptyUniqueVolumeName is a UniqueVolumeName for empty string
	EmptyUniqueVolumeName v1.UniqueVolumeName = v1.UniqueVolumeName("")

	// EmptyNodeName is a NodeName for empty string
	EmptyNodeName types.NodeName = types.NodeName("")
)

Variables

This section is empty.

Functions

func IsAlreadyExists

func IsAlreadyExists(err error) bool

IsAlreadyExists returns true if an error returned from NestedPendingOperations indicates a new operation can not be started because an operation with the same operation name is already executing.

func NewAlreadyExistsError

func NewAlreadyExistsError(key operationKey) error

NewAlreadyExistsError returns a new instance of AlreadyExists error.

Types

type NestedPendingOperations

type NestedPendingOperations interface {

	// Once the operation is complete, the go routine is terminated. If the
	// operation succeeded, its corresponding key is removed from the list of
	// executing operations, allowing a new operation to be started with the key
	// without error. If it failed, the key remains and the exponential
	// backoff status is updated.
	Run(
		volumeName v1.UniqueVolumeName,
		podName volumetypes.UniquePodName,
		nodeName types.NodeName,
		generatedOperations volumetypes.GeneratedOperations) error

	// Wait blocks until all operations are completed. This is typically
	// necessary during tests - the test should wait until all operations finish
	// and evaluate results after that.
	Wait()

	// 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
}

NestedPendingOperations defines the supported set of operations.

func NewNestedPendingOperations

func NewNestedPendingOperations(exponentialBackOffOnError bool) NestedPendingOperations

NewNestedPendingOperations returns a new instance of NestedPendingOperations.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL