util

package
v0.0.0-...-d88201b Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package util provides shared utility functions.

Index

Constants

View Source
const (
	// ErrVolumeOperationAlreadyExistsVolumeID is the error msg logged for concurrent operation.
	ErrVolumeOperationAlreadyExistsVolumeID = "an operation with the given Volume ID already exists"

	// ErrVolumeOperationAlreadyExistsVolumeName is the error msg logged for concurrent operation.
	ErrVolumeOperationAlreadyExistsVolumeName = "an operation with the given Volume name already exists"

	// VolumeOperationAlreadyExistsFmt string format to return for concurrent operation.
	VolumeOperationAlreadyExistsFmt = "an operation with the given Volume ID %s already exists"

	// SnapshotOperationAlreadyExistsFmt string format to return for concurrent operation.
	SnapshotOperationAlreadyExistsFmt = "an operation with the given Snapshot ID %s already exists"
)

Variables

This section is empty.

Functions

func GigaBytesToBytes

func GigaBytesToBytes(gb int64) int64

GigaBytesToBytes gives an exact conversion from GigaBytes to Bytes.

func ParseEndpoint

func ParseEndpoint(endpoint string) (string, string, error)

ParseEndpoint parses the CSI socket endpoint and returns the components scheme and addr.

func RoundUpBytesToGB

func RoundUpBytesToGB(n int64) int64

RoundUpBytesToGB converts a size given in bytes to GB with an upper rounding (it gives the smallest amount in GB which is greater than the original amount).

Types

type OperationLock

type OperationLock struct {
	// contains filtered or unexported fields
}

OperationLock implements a map with atomic operations.

func NewOperationLock

func NewOperationLock() *OperationLock

NewOperationLock returns new OperationLock.

func (*OperationLock) GetCloneLock

func (ol *OperationLock) GetCloneLock(volumeID string) error

GetCloneLock gets the clone lock on given volumeID.

func (*OperationLock) GetDeleteLock

func (ol *OperationLock) GetDeleteLock(volumeID string) error

GetDeleteLock gets the delete lock on given volumeID,ensures that there is no clone,restore and expand operation on given volumeID.

func (*OperationLock) GetExpandLock

func (ol *OperationLock) GetExpandLock(volumeID string) error

GetExpandLock gets the expand lock on given volumeID,ensures that there is no delete and clone operation on given volumeID.

func (*OperationLock) GetRestoreLock

func (ol *OperationLock) GetRestoreLock(volumeID string) error

GetRestoreLock gets the restore lock on given volumeID,ensures that there is no delete operation on given volumeID.

func (*OperationLock) GetSnapshotCreateLock

func (ol *OperationLock) GetSnapshotCreateLock(volumeID string) error

GetSnapshotCreateLock gets the snapshot lock on given volumeID.

func (*OperationLock) ReleaseCloneLock

func (ol *OperationLock) ReleaseCloneLock(volumeID string)

ReleaseCloneLock releases the clone lock on given volumeID.

func (*OperationLock) ReleaseDeleteLock

func (ol *OperationLock) ReleaseDeleteLock(volumeID string)

ReleaseDeleteLock releases the delete lock on given volumeID.

func (*OperationLock) ReleaseExpandLock

func (ol *OperationLock) ReleaseExpandLock(volumeID string)

ReleaseExpandLock releases the expand lock on given volumeID.

func (*OperationLock) ReleaseRestoreLock

func (ol *OperationLock) ReleaseRestoreLock(volumeID string)

ReleaseRestoreLock releases the restore lock on given volumeID.

func (*OperationLock) ReleaseSnapshotCreateLock

func (ol *OperationLock) ReleaseSnapshotCreateLock(volumeID string)

ReleaseSnapshotCreateLock releases the create lock on given volumeID.

type VolumeLocks

type VolumeLocks struct {
	// contains filtered or unexported fields
}

VolumeLocks implements a map with atomic operations. It stores a set of all volume IDs with an ongoing operation.

func NewVolumeLocks

func NewVolumeLocks() *VolumeLocks

NewVolumeLocks returns new VolumeLocks.

func (*VolumeLocks) Release

func (vl *VolumeLocks) Release(volumeID string)

Release deletes the lock on volumeID.

func (*VolumeLocks) TryAcquire

func (vl *VolumeLocks) TryAcquire(volumeID string) bool

TryAcquire tries to acquire the lock for operating on volumeID and returns true if successful. If another operation is already using volumeID, returns false.

Jump to

Keyboard shortcuts

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