mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-06 07:57:35 +00:00
dependencies: pkg/volume
This commit is contained in:
@@ -29,7 +29,7 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/api/v1"
|
||||
"k8s.io/kubernetes/pkg/util/goroutinemap/exponentialbackoff"
|
||||
k8sRuntime "k8s.io/kubernetes/pkg/util/runtime"
|
||||
"k8s.io/kubernetes/pkg/volume/util/types"
|
||||
@@ -40,7 +40,7 @@ const (
|
||||
emptyUniquePodName types.UniquePodName = types.UniquePodName("")
|
||||
|
||||
// emptyUniqueVolumeName is a UniqueVolumeName for empty string
|
||||
emptyUniqueVolumeName api.UniqueVolumeName = api.UniqueVolumeName("")
|
||||
emptyUniqueVolumeName v1.UniqueVolumeName = v1.UniqueVolumeName("")
|
||||
)
|
||||
|
||||
// NestedPendingOperations defines the supported set of operations.
|
||||
@@ -55,7 +55,7 @@ type NestedPendingOperations interface {
|
||||
// concatenation of volumeName and podName is removed from the list of
|
||||
// executing operations allowing a new operation to be started with the
|
||||
// volumeName without error.
|
||||
Run(volumeName api.UniqueVolumeName, podName types.UniquePodName, operationFunc func() error) error
|
||||
Run(volumeName v1.UniqueVolumeName, podName types.UniquePodName, operationFunc func() error) error
|
||||
|
||||
// Wait blocks until all operations are completed. This is typically
|
||||
// necessary during tests - the test should wait until all operations finish
|
||||
@@ -64,7 +64,7 @@ type NestedPendingOperations interface {
|
||||
|
||||
// IsOperationPending returns true if an operation for the given volumeName and podName is pending,
|
||||
// otherwise it returns false
|
||||
IsOperationPending(volumeName api.UniqueVolumeName, podName types.UniquePodName) bool
|
||||
IsOperationPending(volumeName v1.UniqueVolumeName, podName types.UniquePodName) bool
|
||||
}
|
||||
|
||||
// NewNestedPendingOperations returns a new instance of NestedPendingOperations.
|
||||
@@ -85,14 +85,14 @@ type nestedPendingOperations struct {
|
||||
}
|
||||
|
||||
type operation struct {
|
||||
volumeName api.UniqueVolumeName
|
||||
volumeName v1.UniqueVolumeName
|
||||
podName types.UniquePodName
|
||||
operationPending bool
|
||||
expBackoff exponentialbackoff.ExponentialBackoff
|
||||
}
|
||||
|
||||
func (grm *nestedPendingOperations) Run(
|
||||
volumeName api.UniqueVolumeName,
|
||||
volumeName v1.UniqueVolumeName,
|
||||
podName types.UniquePodName,
|
||||
operationFunc func() error) error {
|
||||
grm.lock.Lock()
|
||||
@@ -141,7 +141,7 @@ func (grm *nestedPendingOperations) Run(
|
||||
}
|
||||
|
||||
func (grm *nestedPendingOperations) IsOperationPending(
|
||||
volumeName api.UniqueVolumeName,
|
||||
volumeName v1.UniqueVolumeName,
|
||||
podName types.UniquePodName) bool {
|
||||
|
||||
grm.lock.RLock()
|
||||
@@ -156,7 +156,7 @@ func (grm *nestedPendingOperations) IsOperationPending(
|
||||
|
||||
// This is an internal function and caller should acquire and release the lock
|
||||
func (grm *nestedPendingOperations) isOperationExists(
|
||||
volumeName api.UniqueVolumeName,
|
||||
volumeName v1.UniqueVolumeName,
|
||||
podName types.UniquePodName) (bool, int) {
|
||||
|
||||
// If volumeName is empty, operation can be executed concurrently
|
||||
@@ -184,7 +184,7 @@ func (grm *nestedPendingOperations) isOperationExists(
|
||||
}
|
||||
|
||||
func (grm *nestedPendingOperations) getOperation(
|
||||
volumeName api.UniqueVolumeName,
|
||||
volumeName v1.UniqueVolumeName,
|
||||
podName types.UniquePodName) (uint, error) {
|
||||
// Assumes lock has been acquired by caller.
|
||||
|
||||
@@ -201,7 +201,7 @@ func (grm *nestedPendingOperations) getOperation(
|
||||
|
||||
func (grm *nestedPendingOperations) deleteOperation(
|
||||
// Assumes lock has been acquired by caller.
|
||||
volumeName api.UniqueVolumeName,
|
||||
volumeName v1.UniqueVolumeName,
|
||||
podName types.UniquePodName) {
|
||||
|
||||
opIndex := -1
|
||||
@@ -219,7 +219,7 @@ func (grm *nestedPendingOperations) deleteOperation(
|
||||
}
|
||||
|
||||
func (grm *nestedPendingOperations) operationComplete(
|
||||
volumeName api.UniqueVolumeName, podName types.UniquePodName, err *error) {
|
||||
volumeName v1.UniqueVolumeName, podName types.UniquePodName, err *error) {
|
||||
// Defer operations are executed in Last-In is First-Out order. In this case
|
||||
// the lock is acquired first when operationCompletes begins, and is
|
||||
// released when the method finishes, after the lock is released cond is
|
||||
@@ -272,7 +272,7 @@ func (grm *nestedPendingOperations) Wait() {
|
||||
}
|
||||
|
||||
func getOperationName(
|
||||
volumeName api.UniqueVolumeName, podName types.UniquePodName) string {
|
||||
volumeName v1.UniqueVolumeName, podName types.UniquePodName) string {
|
||||
podNameStr := ""
|
||||
if podName != emptyUniquePodName {
|
||||
podNameStr = fmt.Sprintf(" (%q)", podName)
|
||||
|
||||
Reference in New Issue
Block a user