utils

package
v1.0.0-eks Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// 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"
)
View Source
const (
	NodeMetaDataFile = "/host/etc/cds/node-meta"
	CloudInitDevSize = 8 * 1024
	SockFile         = "/var/run/oss-server.sock"
)

Variables

This section is empty.

Functions

func CreateDir

func CreateDir(target string, mode int) error

CreateDir create the target directory with error handling

func FileExisted

func FileExisted(filename string) bool

FileExisted checks if a file or directory exists

func FsInfo

func FsInfo(path string) (int64, int64, int64, int64, int64, int64, error)

FSInfo linux returns (available bytes, byte capacity, byte usage, total inodes, inodes free, inode usage, error) for the filesystem that path resides upon.

func GetMetrics

func GetMetrics(path string) (*csi.NodeGetVolumeStatsResponse, error)

GetMetrics get path metric

func IsDir

func IsDir(path string) bool

IsDir checks if the target path is directory

func Mounted

func Mounted(mountPath string) bool

Mounted checks whether a volume is mounted

func ReadCloudInitInfo

func ReadCloudInitInfo() (string, error)

func RunCommand

func RunCommand(cmd string) (string, error)

RunCommand runs a given shell command

func RunSYSCommand

func RunSYSCommand(cmd string) error

func SentrySendError added in v1.4.0

func SentrySendError(errorInfo error)

func ServerReachable

func ServerReachable(host, port string, timeout time.Duration) bool

ServerReachable tests whether a server is connection using TCP

func Unmount

func Unmount(mountPath string) error

Unmount tries to unmount a device from the node

func WaitTimeout

func WaitTimeout(wg *sync.WaitGroup, timeout int) bool

WaitTimeOut waits for a mount of time before continues

Types

type Metrics

type Metrics struct {
	// The time at which these stats were updated.
	Time metav1.Time

	// Used represents the total bytes used by the Volume.
	// Note: For block devices this maybe more than the total size of the files.
	Used *resource.Quantity

	// Capacity represents the total capacity (bytes) of the volume's
	// underlying storage. For Volumes that share a filesystem with the host
	// (e.g. emptydir, hostpath) this is the size of the underlying storage,
	// and will not equal Used + Available as the fs is shared.
	Capacity *resource.Quantity

	// Available represents the storage space available (bytes) for the
	// Volume. For Volumes that share a filesystem with the host (e.g.
	// emptydir, hostpath), this is the available space on the underlying
	// storage, and is shared with host processes and other Volumes.
	Available *resource.Quantity

	// InodesUsed represents the total inodes used by the Volume.
	InodesUsed *resource.Quantity

	// Inodes represents the total number of inodes available in the volume.
	// For volumes that share a filesystem with the host (e.g. emptydir, hostpath),
	// this is the inodes available in the underlying storage,
	// and will not equal InodesUsed + InodesFree as the fs is shared.
	Inodes *resource.Quantity

	// InodesFree represent the inodes available for the volume.  For Volumes that share
	// a filesystem with the host (e.g. emptydir, hostpath), this is the free inodes
	// on the underlying storage, and is shared with host processes and other volumes
	InodesFree *resource.Quantity
}

Metrics represents the used and available bytes of the Volume.

type NodeMeta

type NodeMeta struct {
	NodeID string `json:"node_id"`
}

func GetNodeMetadata

func GetNodeMetadata() *NodeMeta

GetNodeId reads node metadata from file

func (*NodeMeta) GetNodeID

func (n *NodeMeta) GetNodeID() string

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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