common

package
v1.0.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	Kib int64 = 1024
	Mib int64 = Kib * 1024
	Gib int64 = Mib * 1024
	Tib int64 = Gib * 1024
)
View Source
const (
	Version              string = "v1.0.0"
	DefaultProvisionName string = "disk.csi.zenlayer.com"
	NodeDriverType       string = "node"
	ControllerDriverType string = "controller"
)
View Source
const (
	FileSystemExt3    string = "ext3"
	FileSystemExt4    string = "ext4"
	FileSystemXfs     string = "xfs"
	DefaultFileSystem string = FileSystemExt4
)
View Source
const (
	ZEC_PLATFORM            string = "Zenlayer Elastic Compute"
	ZEC_SYS_VENDOR_PATH     string = "/sys/class/dmi/id/sys_vendor"     //Vm platform
	ZEC_PRODUCT_FAMILY_PATH string = "/sys/class/dmi/id/product_family" //Vm zone
	ZEC_PRODUCT_SERIAL_PATH string = "/sys/class/dmi/id/product_serial" //Vm console ID
)
View Source
const DefaultTimeFormat = "2006-01-02 15:04:05"
View Source
const FEAT_MOUNTOPT_ENABLE = "enable_mount_opt"
View Source
const Int64Max = int64(^uint64(0) >> 1)
View Source
const KubeletRootDir = "/var/lib/kubelet"
View Source
const KubernetesPluginPathPrefix = "/plugins/kubernetes.io/"
View Source
const (
	OperationPendingFmt = "already an operation for the specified resource %s"
)
View Source
const ZECVMID_LEN = 19 //zec VmID len			example:1455441132925494374
View Source
const ZECVOLID_LEN = 19 //zec DiskId len 		example:1440908808376556310
View Source
const ZECVOLSERIAL_LEN = 20 //zec Disk Serial len 	example:d100om84ggf2oqdh05eg

Variables

View Source
var DefaultResourceGroup string
View Source
var DefaultZone string
View Source
var FeatureGates []string
View Source
var MixDriver bool

Functions

func ByteCeilToGib

func ByteCeilToGib(nByte int64) int

ByteCeilToGib Convert Byte to Gib

func EntryFunction

func EntryFunction(functionName string) (info string, hash string)

func ExitFunction

func ExitFunction(functionName, hash string) (info string)

func FormatAndMount

func FormatAndMount(diskMounter *k8smount.SafeFormatAndMount, source string, target string, fstype string, mkfsOptions []string, mountOptions []string, omitFsCheck bool) error

func FormatNewDisk

func FormatNewDisk(readOnly bool, source, fstype, target string, mkfsOptions, mountOptions []string, diskMounter *k8smount.SafeFormatAndMount) error

func GenCsiVolId

func GenCsiVolId(volid, serial string) (csivolId string)

func GenerateHashInEightBytes

func GenerateHashInEightBytes(input string) string

func GetDiskFStypePTtype

func GetDiskFStypePTtype(disk string) (fstype string, pttype string, err error)

GetDiskFStypePTtype uses 'blkid' to see if the given disk is unformatted

func GetRequestSizeBytes

func GetRequestSizeBytes(capRange *csi.CapacityRange) (int64, error)

GetRequestSizeBytes get minimal required bytes and not exceed limit bytes.

func GetZecEnv

func GetZecEnv() (vmid string, vm_zone string, err error)

func GetZecSecret

func GetZecSecret(akpath string, skpath string) (ak string, pw string, err error)

func GibToByte

func GibToByte(nGib int) int64

GibToByte Convert GiB to Byte

func IsDirEmpty

func IsDirEmpty(name string) (bool, error)

IsDirEmpty check whether the given directory is empty

func IsFileExisting

func IsFileExisting(filename string) bool

IsFileExisting check file exist in volume driver

func IsValidCapacityBytes

func IsValidCapacityBytes(cur int64, capRange *csi.CapacityRange) bool

Valid capacity bytes in capacity range

func NewSafeMounter

func NewSafeMounter() *mount.SafeFormatAndMount

func ParseCsiVolId

func ParseCsiVolId(csivolId string) (volid string, serial string, err error)

func RetryOnError

func RetryOnError(backoff wait.Backoff, fn func() error) error

func VerifyEnv

func VerifyEnv() (platform string, err error)

Types

type ResourceLocks

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

func NewResourceLocks

func NewResourceLocks() *ResourceLocks

func (*ResourceLocks) Release

func (lock *ResourceLocks) Release(resourceID string)

func (*ResourceLocks) TryAcquire

func (lock *ResourceLocks) TryAcquire(resourceID string) bool

type RetryLimiter

type RetryLimiter interface {
	Add(id string)
	Try(id string) bool
	GetMaxRetryTimes() int
	GetCurrentRetryTimes(id string) int
}

func NewRetryLimiter

func NewRetryLimiter(maxRetry int) RetryLimiter

Jump to

Keyboard shortcuts

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