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 ( // VolumeOperationAlreadyExistsVolumeIDFmt string format to return for concurrent operation. VolumeOperationAlreadyExistsVolumeIDFmt = "an operation with the given volume ID %s already exists" // VolumeOperationAlreadyExistsVolumeNameFmt string format to return for concurrent operation. VolumeOperationAlreadyExistsVolumeNameFmt = "an operation with the given volume name %s already exists" // SnapshotOperationAlreadyExistsFmt string format to return for concurrent operation. SnapshotOperationAlreadyExistsFmt = "an operation with the given snapshot ID %s already exists" // TargetPathOperationAlreadyExistsFmt string format to return for concurrent operation on target path. TargetPathOperationAlreadyExistsFmt = "an operation with the given target path %s already exists" )
Variables ¶
This section is empty.
Functions ¶
func GigaBytesToBytes ¶
GigaBytesToBytes gives an exact conversion from GigaBytes to Bytes.
func ParseEndpoint ¶ added in v0.6.0
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 ¶ added in v0.2.0
type OperationLock struct {
// contains filtered or unexported fields
}
OperationLock implements a map with atomic operations.
func NewOperationLock ¶ added in v0.2.0
func NewOperationLock() *OperationLock
NewOperationLock returns new OperationLock.
func (*OperationLock) GetCloneLock ¶ added in v0.2.0
func (ol *OperationLock) GetCloneLock(volumeID string) error
GetCloneLock gets the clone lock on given volumeID.
func (*OperationLock) GetDeleteLock ¶ added in v0.2.0
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 ¶ added in v0.2.0
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 ¶ added in v0.2.0
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 ¶ added in v0.2.0
func (ol *OperationLock) GetSnapshotCreateLock(volumeID string) error
GetSnapshotCreateLock gets the snapshot lock on given volumeID.
func (*OperationLock) ReleaseCloneLock ¶ added in v0.2.0
func (ol *OperationLock) ReleaseCloneLock(volumeID string)
ReleaseCloneLock releases the clone lock on given volumeID.
func (*OperationLock) ReleaseDeleteLock ¶ added in v0.2.0
func (ol *OperationLock) ReleaseDeleteLock(volumeID string)
ReleaseDeleteLock releases the delete lock on given volumeID.
func (*OperationLock) ReleaseExpandLock ¶ added in v0.2.0
func (ol *OperationLock) ReleaseExpandLock(volumeID string)
ReleaseExpandLock releases the expand lock on given volumeID.
func (*OperationLock) ReleaseRestoreLock ¶ added in v0.2.0
func (ol *OperationLock) ReleaseRestoreLock(volumeID string)
ReleaseRestoreLock releases the restore lock on given volumeID.
func (*OperationLock) ReleaseSnapshotCreateLock ¶ added in v0.2.0
func (ol *OperationLock) ReleaseSnapshotCreateLock(volumeID string)
ReleaseSnapshotCreateLock releases the create lock on given volumeID.
type VolumeLocks ¶ added in v0.2.0
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 ¶ added in v0.2.0
func NewVolumeLocks() *VolumeLocks
NewVolumeLocks returns new VolumeLocks.
func (*VolumeLocks) Release ¶ added in v0.2.0
func (vl *VolumeLocks) Release(volumeID string)
Release deletes the lock on volumeID.
func (*VolumeLocks) TryAcquire ¶ added in v0.2.0
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.