Documentation ¶
Index ¶
- Constants
- Variables
- func AppendJSONData(dataFilePath string, appData map[string]string) error
- func Bytes2GiB(volumeSizeBytes int64) int64
- func CheckCmd(cmd string, name string) error
- func CheckCmdArgs(cmd string, args ...string) error
- func CheckParameterValidate(inputs []string) bool
- func CheckRequest(m map[string]string, path string) (bool, error)
- func CheckRequestArgs(m map[string]string) (bool, error)
- func CommandOnNode(args ...string) *exec.Cmd
- func ConnectorRun(cmd ...string) (string, error)
- func CreateDest(dest string) error
- func CreateEvent(recorder record.EventRecorder, objectRef *v1.ObjectReference, eventType string, ...)
- func FindSuggestionByErrorMessage(errMsg, errorType string) string
- func FormatAndMount(diskMounter *k8smount.SafeFormatAndMount, source string, target string, ...) error
- func FormatNewDisk(readOnly bool, source, fstype, target string, ...) error
- func Fsync(f *os.File) error
- func GetAccessModes(caps []*csi.VolumeCapability) *[]string
- func GetCredentialV2() (crev2.Credential, error)
- func GetDiskPtypePTtype(disk string) (fstype string, pttype string, err error)
- func GetFileContent(fileName string) string
- func GetMetaData(resource string) (string, error)
- func GetMetrics(path string) (*csi.NodeGetVolumeStatsResponse, error)
- func GetNvmeDeviceByVolumeID(volumeID string) (device string, err error)
- func GetPodRunTime(req *csi.NodePublishVolumeRequest, clientSet kubernetes.Interface) (string, error)
- func GetPvNameFormPodMnt(mntPath string) string
- func GetRegionID() (string, error)
- func Gi2Bytes(gb int64) int64
- func HasSpecificTagKey(tagKey string, disk *ecs.Disk) (bool, string)
- func IsDir(path string) bool
- func IsDirEmpty(name string) (bool, error)
- func IsDirTmpfs(mounter k8smount.Interface, path string) (bool, error)
- func IsFileExisting(filename string) bool
- func IsKataInstall() bool
- func IsMountPointRunv(mountPoint string) bool
- func IsPathAvailiable(path string) error
- func IsPrivateCloud() bool
- func LoadJSONData(dataFileName string) (map[string]string, error)
- func NewEcsClient(ac AccessControl) (ecsClient *ecs.Client)
- func NewEventRecorder() record.EventRecorder
- func NewStsClient(ac AccessControl) (stsClient *sts.Client)
- func Ping(ipAddress string) (*ping.Statistics, error)
- func ReadJSONFile(file string) (map[string]string, error)
- func RetryGetMetaData(resource string) string
- func RoundUpBytes(volumeSizeBytes int64) int64
- func SetVolumeIOLimit(devicePath string, req *csi.NodePublishVolumeRequest) error
- func ValidatePath(path string) (bool, error)
- func ValidateRequest(m map[string]string) (bool, error)
- func ValidateRun(cmd string) (string, error)
- func WriteAndSyncFile(filename string, data []byte, perm os.FileMode) error
- func WriteJSONFile(obj interface{}, file string) error
- func WriteMetricsInfo(metricsPathPrefix string, req *csi.NodePublishVolumeRequest, metricsTop string, ...)
- func WriteSharedMetricsInfo(metricsPathPrefix string, req *csi.NodePublishVolumeRequest, clientName string, ...)
- func WriteTrunc(dirFd int, filePath string, value string) error
- type AKInfo
- type AccessControl
- type AccessControlMode
- type CommandRunFunc
- type Config
- type ManageTokens
- type MountPoint
- type Mounter
- type RoleAuth
- type VolumeLocks
Constants ¶
const ( // DiskAttachDetach ... DiskAttachDetach = "diskAttachDetach" // DiskProvision ... DiskProvision = "diskProvision" // DiskMount ... DiskMount = "diskMount" // DiskDelete ... DiskDelete = "diskDelete" // NasFilesystemCreate ... NasFilesystemCreate = "nasFilesystemCreate" // NasFilesystemDelete ... NasFilesystemDelete = "nasFilesystemDelete" // NasMountTargetCreate ... NasMountTargetCreate = "nasMountTargetCreate" // NasMountTargetDelete ... NasMountTargetDelete = "nasMountTargetDelete" )
const ( // MetadataURL is metadata url MetadataURL = "http://100.100.100.200/latest/meta-data/" // RegionIDTag is region id RegionIDTag = "region-id" // InstanceIDTag is instance id InstanceIDTag = "instance-id" // DefaultRegion is default region DefaultRegion = "cn-hangzhou" // CsiPluginRunTimeFlagFile tag CsiPluginRunTimeFlagFile = "../alibabacloudcsiplugin.json" // RuncRunTimeTag tag RuncRunTimeTag = "runc" // RunvRunTimeTag tag RunvRunTimeTag = "runv" // ServiceType tag ServiceType = "SERVICE_TYPE" // PluginService represents the csi-plugin type. PluginService = "plugin" // ProvisionerService represents the csi-provisioner type. ProvisionerService = "provisioner" // InstallSnapshotCRD tag InstallSnapshotCRD = "INSTALL_SNAPSHOT_CRD" // MetadataMaxRetryCount ... MetadataMaxRetryCount = 4 // VolDataFileName file VolDataFileName = "vol_data.json" // NsenterCmd is the nsenter command NsenterCmd = "nsenter --mount=/proc/1/ns/mnt --ipc=/proc/1/ns/ipc --net=/proc/1/ns/net --uts=/proc/1/ns/uts" // GiB ... GiB = 1024 * 1024 * 1024 )
const (
// ConfigPath the secret mount file
ConfigPath = "/var/addon/token-config"
)
const PodBlkIOCgroupPath = "/host/sys/fs/cgroup/blkio/kubepods.slice"
Variables ¶
var DiskAttachDetachErrors = map[string]*errorInfo{ "had volume node affinity conflict": { // contains filtered or unexported fields }, "can't find disk:": { // contains filtered or unexported fields }, "instance does not support this disk category.": { // contains filtered or unexported fields }, "The specified disk is not a portable disk.": { // contains filtered or unexported fields }, }
DiskAttachDetachErrors are errors throwed by disk attach
var DiskDeleteErrors = map[string]*errorInfo{}
DiskDeleteErrors are errors throwed by disk delete
var DiskMountErrors = map[string]*errorInfo{}
DiskMountErrors are errors throwed by disk mount
var DiskProvisionErrors = map[string]*errorInfo{ "disk size is not supported.": { // contains filtered or unexported fields }, "The specified AZone inventory is insufficient": { // contains filtered or unexported fields }, }
DiskProvisionErrors are errors throwed by ecs create disk api
var KubeletRootDir = "/var/lib/kubelet"
KubeletRootDir kubelet root dir;
var MountPathWithTLS = "/tls"
MountPathWithTLS tls mount path;
var NasFilesystemCreateErrors = map[string]*errorInfo{}
NasFilesystemCreateErrors are errors throwed by nas create
var NasFilesystemDeleteErrors = map[string]*errorInfo{}
NasFilesystemDeleteErrors are errors throwed by nas filesystem delete
var NasMountTargetCreateErrors = map[string]*errorInfo{}
NasMountTargetCreateErrors are errors throwed by nas mount target create
var NasMountTargetDeleteErrors = map[string]*errorInfo{}
NasMountTargetDeleteErrors are errors throwed by nas mount target delete
var NsenterArgs = []string{"--target=1", "--mount", "--ipc", "--net", "--uts", "--"}
Functions ¶
func AppendJSONData ¶ added in v1.1.7
AppendJSONData append map data to json file.
func CheckCmdArgs ¶ added in v1.1.7
func CheckParameterValidate ¶ added in v1.1.5
CheckParameterValidate is check parameter validating in csi-plugin
func CheckRequest ¶ added in v1.1.7
func CheckRequestArgs ¶ added in v1.1.7
CheckRequestArgs is check string is valid in args map
func CommandOnNode ¶ added in v1.2.1
func ConnectorRun ¶ added in v1.1.7
ConnectorRun Run shell command with host connector host connector is daemon running in host.
func CreateEvent ¶ added in v1.1.1
func CreateEvent(recorder record.EventRecorder, objectRef *v1.ObjectReference, eventType string, reason string, err string)
CreateEvent is create events
func FindSuggestionByErrorMessage ¶ added in v1.1.0
FindSuggestionByErrorMessage get new error message by error type & error message
func FormatAndMount ¶ added in v1.1.7
func FormatAndMount(diskMounter *k8smount.SafeFormatAndMount, source string, target string, fstype string, mkfsOptions []string, mountOptions []string, omitFsCheck bool) error
formatAndMount uses unix utils to format and mount the given disk
func FormatNewDisk ¶ added in v1.2.0
func Fsync ¶ added in v1.1.5
Fsync is a wrapper around file.Sync(). Special handling is needed on darwin platform.
func GetAccessModes ¶ added in v1.2.1
func GetAccessModes(caps []*csi.VolumeCapability) *[]string
GetAccessModes returns a slice containing all of the access modes defined in the passed in VolumeCapabilities.
func GetCredentialV2 ¶ added in v1.4.0
func GetCredentialV2() (crev2.Credential, error)
func GetDiskPtypePTtype ¶ added in v1.2.0
GetDiskPtypePTtype uses 'blkid' to see if the given disk is unformatted
func GetFileContent ¶ added in v1.0.4
GetFileContent get file content
func GetMetaData ¶
GetMetaData get metadata from ecs meta-server
func GetMetrics ¶ added in v1.0.3
func GetMetrics(path string) (*csi.NodeGetVolumeStatsResponse, error)
GetMetrics get path metric
func GetNvmeDeviceByVolumeID ¶ added in v1.3.0
Get NVME device name by diskID; /dev/nvme0n1 0: means device index, 1: means namespace for nvme device; udevadm info --query=all --name=/dev/nvme0n1 | grep ID_SERIAL_SHORT | awk -F= '{print $2}' bp1bcfmvsobfauvxb3ow
func GetPodRunTime ¶ added in v1.0.4
func GetPodRunTime(req *csi.NodePublishVolumeRequest, clientSet kubernetes.Interface) (string, error)
GetPodRunTime Get Pod runtimeclass config Default as runc.
func GetPvNameFormPodMnt ¶ added in v1.1.5
GetPvNameFormPodMnt get pv name
func GetRegionID ¶ added in v1.3.0
GetRegionID Get RegionID from Environment Variables or Metadata
func HasSpecificTagKey ¶ added in v1.1.7
func IsDirEmpty ¶ added in v1.0.1
IsDirEmpty return status of dir empty or not
func IsDirTmpfs ¶ added in v1.1.5
IsDirTmpfs check path is tmpfs mounted or not
func IsFileExisting ¶
IsFileExisting check file exist in volume driver or not
func IsKataInstall ¶ added in v1.1.7
func IsKataInstall() bool
IsKataInstall check kata daemon installed
func IsMountPointRunv ¶ added in v1.0.4
IsMountPointRunv check the mountpoint is runv style. Remember to check this is not a regular mountpoint before calling this function.
func IsPrivateCloud ¶ added in v1.1.7
func IsPrivateCloud() bool
func LoadJSONData ¶ added in v1.1.7
LoadJSONData loads json info from specified json file
func NewEcsClient ¶ added in v1.0.1
func NewEcsClient(ac AccessControl) (ecsClient *ecs.Client)
NewEcsClient create a ecsClient object
func NewEventRecorder ¶ added in v1.1.0
func NewEventRecorder() record.EventRecorder
NewEventRecorder is create snapshots event recorder
func NewStsClient ¶ added in v1.4.0
func NewStsClient(ac AccessControl) (stsClient *sts.Client)
NewStsClient create a stsClient object
func Ping ¶ added in v1.1.1
func Ping(ipAddress string) (*ping.Statistics, error)
Ping check network like shell ping command
func ReadJSONFile ¶ added in v1.0.1
ReadJSONFile return a json object
func RetryGetMetaData ¶ added in v1.1.5
RetryGetMetaData ...
func RoundUpBytes ¶ added in v1.2.1
RoundUpBytes rounds up the volume size in bytes upto multiplications of GiB in the unit of Bytes
func SetVolumeIOLimit ¶ added in v1.1.7
func SetVolumeIOLimit(devicePath string, req *csi.NodePublishVolumeRequest) error
SetVolumeIOLimit config io limit for device readIOPS: 1000 writeIOPS: 10000 readBPS: 100K writeBPS: 1M
func ValidatePath ¶ added in v1.1.7
ValidatePath is check path string is valid
func WriteAndSyncFile ¶ added in v1.1.5
WriteAndSyncFile behaves just like ioutil.WriteFile in the standard library, but calls Sync before closing the file. WriteAndSyncFile guarantees the data is synced if there is no error returned.
func WriteJSONFile ¶ added in v1.0.1
WriteJSONFile save json data to file
func WriteMetricsInfo ¶ added in v1.1.7
func WriteSharedMetricsInfo ¶ added in v1.4.0
Types ¶
type AKInfo ¶ added in v1.0.5
type AKInfo struct { // AccessKeyId access key id AccessKeyID string `json:"access.key.id"` // AccessKeySecret access key secret AccessKeySecret string `json:"access.key.secret"` // SecurityToken security token SecurityToken string `json:"security.token"` // Expiration expiration duration Expiration string `json:"expiration"` // Keyring key ring Keyring string `json:"keyring"` // RoleAccessKeyId key RoleAccessKeyID string `json:"role.access.key.id"` // RoleAccessKeySecret key RoleAccessKeySecret string `json:"role.access.key.secret"` // RoleArn key RoleArn string `json:"role.arn"` }
AKInfo access key info
type AccessControl ¶ added in v1.1.6
type AccessControl struct { AccessKeyID string AccessKeySecret string StsToken string RoleArn string Config *sdk.Config Credential auth.Credential UseMode AccessControlMode }
AccessControl is access control option
func GetAccessControl ¶ added in v1.1.6
func GetAccessControl() AccessControl
GetAccessControl 1、Read default ak from local file. 2、If local default ak is not exist, then read from STS.
func GetDefaultRoleAK ¶ added in v1.1.5
func GetDefaultRoleAK() AccessControl
GetDefaultRoleAK 返回角色扮演账号AK, SK, role arn
type AccessControlMode ¶ added in v1.1.6
type AccessControlMode int
AccessControlMode is int, represents different modes
const ( AccessKey AccessControlMode = iota ManagedToken EcsRAMRole Credential RoleArnToken OIDCToken )
AccessControlMode includes AccessKey, ManagedToken, EcsRamRole, Credential, RoleArnToken, five types of access control
type CommandRunFunc ¶ added in v1.1.1
CommandRunFunc define the run function in utils for ut
type ManageTokens ¶ added in v1.1.5
type ManageTokens struct { // AccessKeyId key AccessKeyID string // AccessKeySecret key AccessKeySecret string // SecurityToken key SecurityToken string // RoleAccessKeyId key RoleAccessKeyID string // RoleAccessKeySecret key RoleAccessKeySecret string // RoleArn key RoleArn string // expire time ExpireAt time.Time }
ManageTokens 定义资源账号 和 角色扮演账号
type MountPoint ¶ added in v1.1.7
type MountPoint struct { Device string Path string Type string Opts []string // Opts may contain sensitive mount options (like passwords) and MUST be treated as such (e.g. not logged). Freq int Pass int }
MountPoint represents a single line in /proc/mounts or /etc/fstab.
type Mounter ¶ added in v1.0.1
type Mounter interface { // If the folder doesn't exist, it will call 'mkdir -p' EnsureFolder(target string) error // If the block doesn't exist, create it EnsureBlock(target string) error // Format formats the source with the given filesystem type Format(source, fsType string) error // Mount mounts source to target with the given fstype and options. Mount(source, target, fsType string, options ...string) error // Mount mounts source to target for block file. MountBlock(source, target string, options ...string) error // Unmount unmounts the given target Unmount(target string) error HasMountRefs(mountPath string, mountRefs []string) bool }
Mounter is responsible for formatting and mounting volumes
func NewMounter ¶ added in v1.0.1
func NewMounter() Mounter
NewMounter returns a new mounter instance
type RoleAuth ¶ added in v1.0.1
type RoleAuth struct { AccessKeyID string AccessKeySecret string Expiration time.Time SecurityToken string LastUpdated time.Time Code string }
RoleAuth define STS Token Response
type VolumeLocks ¶ added in v1.3.0
type VolumeLocks struct {
// contains filtered or unexported fields
}
func NewVolumeLocks ¶ added in v1.3.0
func NewVolumeLocks() *VolumeLocks
func (*VolumeLocks) Release ¶ added in v1.3.0
func (lock *VolumeLocks) Release(volumeID string)
Release releases lock in volume level
func (*VolumeLocks) TryAcquire ¶ added in v1.3.0
func (lock *VolumeLocks) TryAcquire(volumeID string) bool
TryAcquire tries to acquire the lock for operating on resourceID and returns true if successful. If another operation is already using resourceID, returns false.