Documentation
¶
Overview ¶
Package util provides shared utility functions.
Index ¶
- Constants
- func GigaBytesToBytes(gb int64) int64
- func ParseEndpoint(endpoint string) (string, string, error)
- func RoundUpBytesToGB(n int64) int64
- type OperationLock
- func (ol *OperationLock) GetCloneLock(volumeID string) error
- func (ol *OperationLock) GetDeleteLock(volumeID string) error
- func (ol *OperationLock) GetExpandLock(volumeID string) error
- func (ol *OperationLock) GetRestoreLock(volumeID string) error
- func (ol *OperationLock) GetSnapshotCreateLock(volumeID string) error
- func (ol *OperationLock) ReleaseCloneLock(volumeID string)
- func (ol *OperationLock) ReleaseDeleteLock(volumeID string)
- func (ol *OperationLock) ReleaseExpandLock(volumeID string)
- func (ol *OperationLock) ReleaseRestoreLock(volumeID string)
- func (ol *OperationLock) ReleaseSnapshotCreateLock(volumeID string)
- type VolumeLocks
Constants ¶
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 ¶
GigaBytesToBytes gives an exact conversion from GigaBytes to Bytes.
func ParseEndpoint ¶
ParseEndpoint parses the CSI socket endpoint and returns the components scheme and addr.
func RoundUpBytesToGB ¶
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 (*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.