Documentation ¶
Index ¶
- Constants
- Variables
- func AppendJSONData(dataFilePath string, appData map[string]string) error
- func Bytes2GiB(volumeSizeBytes int64) int64
- 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 GetDiskFStypePTtype(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 GetPodFromContextOrK8s(ctx context.Context, client kubernetes.Interface, ...) (*v1.Pod, error)
- func GetPodRunTime(ctx context.Context, req *csi.NodePublishVolumeRequest, ...) string
- 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 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 ValidatePath(path string) (bool, error)
- func WithPodInfo(ctx context.Context, client kubernetes.Interface, ...) (context.Context, *v1.Pod)
- 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, ...)
- type AKInfo
- type AccessControl
- type AccessControlMode
- type Config
- type ManageTokens
- type MountPoint
- type Mounter
- type PodCGroup
- type RoleAuth
- type ServiceType
- 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/" // ECS worker role resource url in metadata server WorkerRoleResource = "ram/security-credentials/" // 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" // RunvRunTimeTag tag RundRunTimeTag = "rund" // ServiceType tag ServiceTypeEnv = "SERVICE_TYPE" // PluginService represents the csi-plugin type. PluginService = "plugin" // ProvisionerService represents the csi-provisioner type. ProvisionerService = "provisioner" // MetadataMaxRetryCount ... MetadataMaxRetryCount = 4 // VolDataFileName file VolDataFileName = "vol_data.json" // GiB ... GiB = 1024 * 1024 * 1024 PodNameKey = "csi.storage.k8s.io/pod.name" PodNamespaceKey = "csi.storage.k8s.io/pod.namespace" )
const CGROUPFS_MOUNT_PATH = "/host/sys/fs/cgroup"
CGROUPFS_MOUNT_PATH is the path to the host cgroupfs mounted in the container
const (
// ConfigPath the secret mount file
ConfigPath = "/var/addon/token-config"
)
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 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 GetDiskFStypePTtype ¶ added in v1.6.0
GetDiskFStypePTtype 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 GetPodFromContextOrK8s ¶ added in v1.6.0
func GetPodFromContextOrK8s(ctx context.Context, client kubernetes.Interface, req *csi.NodePublishVolumeRequest) (*v1.Pod, error)
func GetPodRunTime ¶ added in v1.0.4
func GetPodRunTime(ctx context.Context, req *csi.NodePublishVolumeRequest, clientSet kubernetes.Interface) string
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 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 TODO: The current region is set to the default value. Need to obtain the actual region.
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 ValidatePath ¶ added in v1.1.7
ValidatePath is check path string is valid
func WithPodInfo ¶ added in v1.6.0
func WithPodInfo(ctx context.Context, client kubernetes.Interface, req *csi.NodePublishVolumeRequest) (context.Context, *v1.Pod)
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 Config ¶ added in v1.3.0
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 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 NewFakeMounter ¶ added in v1.6.0
func NewFakeMounter() Mounter
func NewMounter ¶ added in v1.0.1
func NewMounter() Mounter
NewMounter returns a new mounter instance
type PodCGroup ¶ added in v1.5.0
type PodCGroup struct {
// contains filtered or unexported fields
}
func NewPodCGroup ¶ added in v1.5.0
func (*PodCGroup) ApplyConfig ¶ added in v1.5.0
func (cg *PodCGroup) ApplyConfig(devicePath string, req *csi.NodePublishVolumeRequest) error
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 ServiceType ¶ added in v1.1.1
type ServiceType int
const ( Controller ServiceType = 1 << iota Node )
func GetServiceType ¶ added in v1.6.0
func GetServiceType(runAsController, runControllerService, runNodeService bool) ServiceType
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.