Documentation ¶
Index ¶
- Constants
- Variables
- func BdfHealthCheck()
- func CheckDeviceAvailable(devicePath, volumeID, targetPath string) error
- func DescribeDiskInstanceEvents(instanceId string, ecsClient *ecs.Client) (eventMaps map[string]string, err error)
- func DingTalk(msg string)
- func ExecCheckOutput(cmd string, args ...string) (io.Reader, error)
- func FindLines(reader io.Reader, keyword string) []string
- func GetAvailableDiskTypes(ctx context.Context, c cloud.ECSInterface, m metadata.MetadataProvider) (types []string, err error)
- func GetDeviceByBdf(bdf string, enLog bool) (device string, err error)
- func GetDiskFormat(disk string) (string, string, error)
- func GetVolumeDeviceName(diskID string) (string, error)
- func GetVolumeIDByDevice(device string) (volumeID string, err error)
- func GlobalConfigSet(m metadata.MetadataProvider) *restclient.Config
- func IohubSriovBind(bdf string) error
- func IohubSriovUnbind(bdf string) error
- func IsDirEmpty(name string) (bool, error)
- func IsFileExisting(filename string) bool
- func IsNoSuchDeviceErr(err error) bool
- func IsVFInstance() bool
- func IsVFNode() bool
- func NewControllerServer(d *csicommon.CSIDriver, client *crd.Clientset) csi.ControllerServer
- func NewIdentityServer(d *csicommon.CSIDriver) csi.IdentityServer
- func NewNodeServer(d *csicommon.CSIDriver, m metadata.MetadataProvider) csi.NodeServer
- func SetEcsEndPoint(regionID string)
- func StopDiskOperationRetry(instanceId string, ecsClient *ecs.Client) bool
- func VirtioPciBind(bdf string) error
- func VirtioPciUnbind(bdf string) error
- type AttachDetachSlots
- type BdfAttachInfo
- type Category
- type CategoryDesc
- type DISK
- type DefaultOptions
- type DeviceManager
- func (m *DeviceManager) GetDeviceByVolumeID(volumeID string) (string, error)
- func (m *DeviceManager) GetDeviceNumberFromBlockDevice(blockDevice, busPrefix string) (string, error)
- func (m *DeviceManager) GetDeviceRootAndPartitionIndex(devicePath string) (root string, partitionIndex string, err error)
- func (m *DeviceManager) GetRootBlockByVolumeID(volumeID string) (string, error)
- func (m *DeviceManager) WriteSysfs(devicePath, name string, value []byte) error
- type DingMsg
- type DingText
- type DiskSize
- type Driver
- type GlobalConfig
- type MachineType
- type PerNodeSlots
- type PerformanceLevel
- type PerformanceLevelDesc
- type QueryResponse
- type RoleAuth
- type SizeRange
Constants ¶
const ( // VfBar0Sz value VfBar0Sz = 0x1000 // DevIDOffsetInBar0 value DevIDOffsetInBar0 = 0x100 // MaxVfNum value MaxVfNum = 256 // BlkIDSz value BlkIDSz = 20 // InstanceStatusStopped ecs stopped status InstanceStatusStopped = "Stopped" // DiskBdfTagKey disk bdf tag DiskBdfTagKey = "bdf.csi.aliyun.com" // DiskBdfCheckTagKey disk bdf check tag DiskBdfCheckTagKey = "check.bdf.csi.aliyun.com" // Vfhp Reconcile period VfhpReconcilePeriod = 600 )
const ( // BdfVolumeHang tag BdfVolumeHang = "BdfVolumeHang" // BdfVolumeUnUsed tag BdfVolumeUnUsed = "BdfVolumeUnUsed" )
const ( DiskCommon Category = "cloud" DiskEfficiency Category = "cloud_efficiency" DiskSSD Category = "cloud_ssd" DiskESSD Category = "cloud_essd" DiskESSDAuto Category = "cloud_auto" DiskESSDEntry Category = "cloud_essd_entry" DiskPPerf Category = "cloud_pperf" DiskSPerf Category = "cloud_sperf" PERFORMANCE_LEVEL0 PerformanceLevel = "PL0" PERFORMANCE_LEVEL1 PerformanceLevel = "PL1" PERFORMANCE_LEVEL2 PerformanceLevel = "PL2" PERFORMANCE_LEVEL3 PerformanceLevel = "PL3" )
const ( DISK_DELETE_INIT_TIMEOUT = 5 * time.Minute DISK_RESIZE_PROCESSING_TIMEOUT = 30 * time.Second )
const ( // ESSD_PERFORMANCE_LEVEL is storage class ESSD_PERFORMANCE_LEVEL = "performanceLevel" // DISKTAGKEY1 tag DISKTAGKEY1 = "k8s.aliyun.com" // DISKTAGVALUE1 value DISKTAGVALUE1 = "true" // DISKTAGKEY2 key DISKTAGKEY2 = "createdby" // DISKTAGVALUE2 value DISKTAGVALUE2 = "alibabacloud-csi-plugin" // DISKTAGKEY3 key DISKTAGKEY3 = "ack.aliyun.com" // ECS snapshot tag from old version, keep it for compatibility SNAPSHOTTAGKEY1 = "force.delete.snapshot.k8s.aliyun.com" )
const ( SNAPSHOTTYPE = "snapshotType" INSTANTACCESS = "InstantAccess" RETENTIONDAYS = "retentionDays" INSTANTACCESSRETENTIONDAYS = "instantAccessRetentionDays" SNAPSHOTRESOURCEGROUPID = "resourceGroupId" SNAPSHOT_TAG_PREFIX = "snapshotTags/" )
keys used in CreateSnapshotRequest.Parameters
const ( // DiskSnapshotID means snapshot id DiskSnapshotID = "csi.alibabacloud.com/disk-snapshot-id" // IAVolumeSnapshotKey tag IAVolumeSnapshotKey = "csi.alibabacloud.com/snapshot-ia" // SnapshotRequestTag interval limit SnapshotRequestTag = "SNAPSHOT_REQUEST_INTERVAL" // DefaultVolumeSnapshotClass ... DefaultVolumeSnapshotClass = "alibabacloud-disk-snapshot" // MultiAttach tag MultiAttach = "multiAttach" // MinimumDiskSizeInGB ... MinimumDiskSizeInGB = 20 // MinimumDiskSizeInBytes ... MinimumDiskSizeInBytes = 21474836480 // LastApplyKey key LastApplyKey = "kubectl.kubernetes.io/last-applied-configuration" // StorageProvisionerKey key StorageProvisionerKey = "volume.beta.kubernetes.io/storage-provisioner" // DocumentURL document URL DocumentURL = "http://100.100.100.200/latest/dynamic/instance-identity/document" // IncorrectDiskStatus incorrect disk status IncorrectDiskStatus = "IncorrectDiskStatus" // NeverAttached status belongs to IncorrectDiskStatus NeverAttached = "IncorrectDiskStatus.NeverAttached" // DiskCreatingSnapshot ... DiskCreatingSnapshot = "DiskCreatingSnapshot" // UserNotInTheWhiteList tag UserNotInTheWhiteList = "UserNotInTheWhiteList" // ZoneIDTag tag ZoneIDTag = "zone-id" DiskNotAvailable = "InvalidDataDiskCategory" // InvalidDataDiskCategory.ValueNotSupported/NotSupported DiskNotAvailableVer2 = "'DataDisk.n.Category' is not valid in this region." DiskSizeNotAvailable1 = "InvalidDiskSize.NotSupported" // for cloud/cloud_efficiency/cloud_ssd DiskSizeNotAvailable2 = "InvalidDataDiskSize.ValueNotSupported" // for cloud_auto DiskPerformanceLevelNotMatch = "OperationDenied.PerformanceLevelNotMatch" // for cloud_essd DiskInvalidPL = "InvalidPerformanceLevel.Malformed" DiskIopsLimitExceeded = "InvalidProvisionedIops.LimitExceed" DiskLimitExceeded = "InstanceDiskLimitExceeded" NotSupportDiskCategory = "NotSupportDiskCategory" DiskNotPortable = "DiskNotPortable" IdempotentParameterMismatch = "IdempotentParameterMismatch" SnapshotNotFound = "InvalidSnapshotId.NotFound" InstanceNotFound = "InvalidInstanceId.NotFound" // DiskHighAvail tag DiskHighAvail = "available" // MBSIZE tag MBSIZE = 1024 * 1024 // GBSIZE tag GBSIZE = 1024 * MBSIZE // ZoneID ... ZoneID = "zoneId" // NodeSchedueTag in annotations NodeSchedueTag = "volume.kubernetes.io/selected-node" // RetryMaxTimes ... RetryMaxTimes = 5 VolumeDeleteAutoSnapshotKey = "csi.alibabacloud.com/volume-delete-autosnapshot-retentiondays" VOLUME_EXPAND_AUTO_SNAPSHOT_OP_KEY = "volumeExpandAutoSnapshot" VOLUME_DELETE_AUTO_SNAPSHOT_OP_RETENT_DAYS_KEY = "volumeDeleteSnapshotRetentionDays" PROVISIONED_IOPS_KEY = "provisionedIops" BURSTING_ENABLED_KEY = "burstingEnabled" CSI_DEFAULT_FS_TYPE = "csi.storage.k8s.io/fstype" FS_TYPE = "fsType" EXT4_FSTYPE = "ext4" EXT3_FSTYPE = "ext3" XFS_FSTYPE = "xfs" NTFS_FSTYPE = "ntfs" SNAPSHOT_MAX_RETENTION_DAYS = 65536 SNAPSHOT_MIN_RETENTION_DAYS = 1 )
const ( TopologyZoneKey = "topology." + driverName + "/zone" TopologyMultiZonePrefix = TopologyZoneKey + "-" )
PluginFolder defines the location of diskplugin
const ( // DiskStatusInuse disk inuse status DiskStatusInuse = "In_use" // DiskStatusAttaching disk attaching status DiskStatusAttaching = "Attaching" // DiskStatusAvailable disk available status DiskStatusAvailable = "Available" // DiskStatusAttached disk attached status DiskStatusAttached = "attached" // DiskStatusDetached disk detached status DiskStatusDetached = "detached" SharedEnable = "shared" // SysConfigTag tag SysConfigTag = "sysConfig" // SysConfigTag tag OmitFilesystemCheck = "omitfsck" // MkfsOptions tag MkfsOptions = "mkfsOptions" // DiskAttachedKey attached key DiskAttachedKey = "k8s.aliyun.com" // DiskAttachedValue attached value DiskAttachedValue = "true" // VolumeDir volume dir VolumeDir = "/host/etc/kubernetes/volumes/disk/" // RundSocketDir dir RundSocketDir = "/host/etc/kubernetes/volumes/rund/" // VolumeDirRemove volume dir remove VolumeDirRemove = "/host/etc/kubernetes/volumes/disk/remove" // InputOutputErr tag InputOutputErr = "input/output error" // DiskMultiTenantEnable Enable disk multi-tenant mode DiskMultiTenantEnable = "DISK_MULTI_TENANT_ENABLE" // TenantUserUID tag TenantUserUID = "alibabacloud.com/user-uid" // CreateDiskARN ARN parameter of the CreateDisk interface CreateDiskARN = "alibabacloud.com/createdisk-arn" // PVC annotation key of KMS key ID, override the storage class parameter kmsKeyId KMSKeyID = "alibabacloud.com/kms-key-id" // DefaultMaxVolumesPerNode define default max ebs one node DefaultMaxVolumesPerNode = 15 // MaxVolumesPerNodeLimit define limit max ebs one node MaxVolumesPerNodeLimit = 64 // NOUUID is xfs fs mount opts NOUUID = "nouuid" // NodeMultiZoneEnable Enable node multi-zone mode NodeMultiZoneEnable = "NODE_MULTI_ZONE_ENABLE" // BDFTypeDevice defines the prefix of bdf number BDFTypeDevice = "0000:" // BDFTypeBus defines bdf bus type BDFTypeBus = "pci" // DFBusTypeDevice defines the prefix of dfnumber DFBusTypeDevice = "dfvirtio" // DFBusTypeBus defines df bus type DFBusTypeBus = "dragonfly" // DFBusTypeVFIO defines df bus vfio driver type DFBusTypeVFIO = "vfio-dfbus" // DFBusTypeVIRTIO defines df bus virtio driver type DFBusTypeVIRTIO = "dfbus-mmio" // PCITypeVFIO defines pci bus vfio driver type PCITypeVFIO = "vfio-pci" // PCITypeVIRTIO defines pci bus virtio driver type PCITypeVIRTIO = "virtio-pci" )
const DISK_TAG_PREFIX = "diskTags/"
Variables ¶
var ( // BLOCKVOLUMEPREFIX block volume mount prefix BLOCKVOLUMEPREFIX = filepath.Join(utils.KubeletRootDir, "/plugins/kubernetes.io/csi/volumeDevices/publish") // DiskXattrName xattr is applied on the block device file to indicate that it is managed by the CSI driver. // Value is the disk ID. // Linux only support trusted namespace xattr in tmpfs before kernel v6.6, // but setting trusted xaattr requires CAP_SYS_ADMIN capability, we may use user namespace instead in unit tests. DiskXattrName = "trusted.csi-managed-disk" )
var ( // KubernetesAlicloudIdentity is the system identity for ecs client request KubernetesAlicloudIdentity = fmt.Sprintf("Kubernetes.Alicloud/CsiProvision.Disk-%s", version.VERSION) SupportedFilesystemTypes = sets.New(EXT4_FSTYPE, EXT3_FSTYPE, XFS_FSTYPE, NTFS_FSTYPE) )
var AllCategories = map[Category]CategoryDesc{ DiskCommon: {}, DiskEfficiency: { Size: SizeRange{Min: 20, Max: 65536}, }, DiskSSD: { Size: SizeRange{Min: 20, Max: 65536}, }, DiskESSD: { Size: SizeRange{Min: 20, Max: 65536}, PerformanceLevel: map[PerformanceLevel]PerformanceLevelDesc{ PERFORMANCE_LEVEL0: {Size: SizeRange{Min: 1, Max: 65536}}, PERFORMANCE_LEVEL1: {Size: SizeRange{Min: 20, Max: 65536}}, PERFORMANCE_LEVEL2: {Size: SizeRange{Min: 461, Max: 65536}}, PERFORMANCE_LEVEL3: {Size: SizeRange{Min: 1261, Max: 65536}}, }, InstantAccessSnapshot: true, }, DiskESSDAuto: { Size: SizeRange{Min: 1, Max: 65536}, InstantAccessSnapshot: true, ProvisionedIops: true, Bursting: true, }, DiskESSDEntry: { Size: SizeRange{Min: 10, Max: 65536}, }, DiskSharedSSD: {}, DiskSharedEfficiency: {}, DiskPPerf: {}, DiskSPerf: {}, }
var DEFAULT_VMFATAL_EVENTS = []string{
"ecs_alarm_center.vm.guest_os_oom:critical",
"ecs_alarm_center.vm.guest_os_kernel_panic:critical",
"ecs_alarm_center.vm.guest_os_kernel_panic:fatal",
"ecs_alarm_center.vm.vmexit_exception_vm_hang:fatal",
}
var DefaultDeviceManager = &DeviceManager{ DevTmpFS: utilsio.RealDevTmpFS{}, DevicePath: "/dev", SysfsPath: "/sys", }
var DingURL = os.Getenv("Ding_URL")
DingURL tag
var ErrParameterMismatch = errors.New("parameter mismatch")
var ObjReference = &v1.ObjectReference{ Kind: "BdfVolumeCheck", Name: GlobalConfigVar.NodeID, UID: "", Namespace: "", }
ObjReference reference for bdf volume
var SnapshotRequestInterval = int64(10)
SnapshotRequestInterval snapshot request limit
var SnapshotRequestMap = map[string]int64{}
SnapshotRequestMap snapshot request limit
Functions ¶
func CheckDeviceAvailable ¶ added in v1.4.0
func DescribeDiskInstanceEvents ¶ added in v1.1.7
func ExecCheckOutput ¶ added in v1.0.5
ExecCheckOutput check output
func GetAvailableDiskTypes ¶ added in v1.3.0
func GetAvailableDiskTypes(ctx context.Context, c cloud.ECSInterface, m metadata.MetadataProvider) (types []string, err error)
func GetDeviceByBdf ¶ added in v1.0.5
GetDeviceByBdf get device name by bdf
func GetDiskFormat ¶ added in v1.1.3
GetDiskFormat uses 'blkid' to see if the given disk is unformatted
func GetVolumeDeviceName ¶ added in v1.0.3
GetVolumeDeviceName get device name
func GetVolumeIDByDevice ¶ added in v1.1.0
GetVolumeIDByDevice get volumeID by specific deivce name according to by-id dictionary
func GlobalConfigSet ¶ added in v1.0.3
func GlobalConfigSet(m metadata.MetadataProvider) *restclient.Config
GlobalConfigSet set Global Config
func IohubSriovBind ¶ added in v1.0.5
IohubSriovBind io hub bind
func IohubSriovUnbind ¶ added in v1.0.5
IohubSriovUnbind io hub unbind
func IsDirEmpty ¶ added in v1.0.1
IsDirEmpty check whether the given directory is empty
func IsFileExisting ¶
IsFileExisting check file exist in volume driver
func IsNoSuchDeviceErr ¶ added in v1.0.5
IsNoSuchDeviceErr nd device error
func IsVFNode ¶ added in v1.0.6
func IsVFNode() bool
IsVFNode returns whether the current node is vf
func NewControllerServer ¶
NewControllerServer is to create controller server
func NewIdentityServer ¶
func NewIdentityServer(d *csicommon.CSIDriver) csi.IdentityServer
NewIdentityServer create identity server
func NewNodeServer ¶
func NewNodeServer(d *csicommon.CSIDriver, m metadata.MetadataProvider) csi.NodeServer
NewNodeServer creates node server
func SetEcsEndPoint ¶ added in v1.0.2
func SetEcsEndPoint(regionID string)
SetEcsEndPoint Set Endpoint for Ecs
func StopDiskOperationRetry ¶ added in v1.1.7
func VirtioPciUnbind ¶ added in v1.0.5
VirtioPciUnbind pci unbind
Types ¶
type AttachDetachSlots ¶ added in v1.4.0
type AttachDetachSlots interface {
GetSlotFor(node string) adSlot
}
func NewPerNodeSlots ¶ added in v1.5.0
func NewPerNodeSlots(makeSlot func() adSlot) AttachDetachSlots
func NewSlots ¶ added in v1.5.0
func NewSlots(serialDetach, serialAttach bool) AttachDetachSlots
type BdfAttachInfo ¶ added in v1.0.5
type BdfAttachInfo struct { Depend bool `json:"depend"` LastAttachedNodeID string `json:"last_attached_node_id"` }
BdfAttachInfo type
type CategoryDesc ¶ added in v1.5.0
type CategoryDesc struct { Size SizeRange PerformanceLevel map[PerformanceLevel]PerformanceLevelDesc InstantAccessSnapshot bool ProvisionedIops bool Bursting bool }
type DISK ¶ added in v1.0.1
type DISK struct {
// contains filtered or unexported fields
}
DISK the DISK object
type DefaultOptions ¶
type DefaultOptions struct { Global struct { KubernetesClusterTag string AccessKeyID string `json:"accessKeyID"` AccessKeySecret string `json:"accessKeySecret"` Region string `json:"region"` } }
DefaultOptions is the struct for access key
type DeviceManager ¶ added in v1.5.0
type DeviceManager struct { DevTmpFS utilsio.DevTmpFS // The path to the directory containing the device files. // This is usually /dev. DevicePath string // The path to the directory mounted as sysfs. // This is usually /sys. SysfsPath string // Disable read serial from sysfs DisableSerial bool // Support sole alreadly formatted disk partition EnableDiskPartition bool }
func (*DeviceManager) GetDeviceByVolumeID ¶ added in v1.5.0
func (m *DeviceManager) GetDeviceByVolumeID(volumeID string) (string, error)
func (*DeviceManager) GetDeviceNumberFromBlockDevice ¶ added in v1.5.0
func (m *DeviceManager) GetDeviceNumberFromBlockDevice(blockDevice, busPrefix string) (string, error)
func (*DeviceManager) GetDeviceRootAndPartitionIndex ¶ added in v1.5.0
func (m *DeviceManager) GetDeviceRootAndPartitionIndex(devicePath string) (root string, partitionIndex string, err error)
func (*DeviceManager) GetRootBlockByVolumeID ¶ added in v1.5.0
func (m *DeviceManager) GetRootBlockByVolumeID(volumeID string) (string, error)
GetRootBlockByVolumeID first try to find the device by device link like: /dev/disk/by-id/virtio-wz9cu3ctp6aj1iagco4h -> ../../vdc If that fails, query the kernel by sysfs to find the device by serial.
Returns the path to a block special file. Caller should not assume any other special property of the returned path.
func (*DeviceManager) WriteSysfs ¶ added in v1.5.0
func (m *DeviceManager) WriteSysfs(devicePath, name string, value []byte) error
type DingText ¶ added in v1.1.4
type DingText struct {
Content string `json:"content"`
}
DingText struct
type Driver ¶ added in v1.5.0
type Driver interface { CurentDriver() (string, error) UnbindDriver() error BindDriver(targetDriver string) error GetDeviceNumber() string }
func NewDeviceDriver ¶ added in v1.5.0
type GlobalConfig ¶ added in v1.0.3
type GlobalConfig struct { EcsClient *ecs.Client Region string NodeID string DiskTagEnable bool AttachDetachSlots AttachDetachSlots ADControllerEnable bool DetachDisabled bool MetricEnable bool DetachBeforeAttach bool DetachBeforeDelete bool DiskBdfEnable bool ClientSet *kubernetes.Clientset ClusterID string ControllerService bool BdfHealthCheck bool DiskMultiTenantEnable bool CheckBDFHotPlugin bool SnapClient *snapClientset.Clientset NodeMultiZoneEnable bool WaitBeforeAttach bool AddonVMFatalEvents []string RequestBaseInfo map[string]string SnapshotBeforeDelete bool OmitFilesystemCheck bool DiskAllowAllType bool }
GlobalConfig save global values for plugin
var (
GlobalConfigVar GlobalConfig
)
define global variable
type MachineType ¶ added in v1.5.0
type MachineType int
const ( BDF MachineType = iota // 0 DFBus // 1 )
func (MachineType) BusName ¶ added in v1.5.0
func (_type MachineType) BusName() string
func (MachineType) BusPrefix ¶ added in v1.5.0
func (_type MachineType) BusPrefix() string
type PerNodeSlots ¶ added in v1.5.0
type PerNodeSlots struct {
// contains filtered or unexported fields
}
func (*PerNodeSlots) GetSlotFor ¶ added in v1.5.0
func (a *PerNodeSlots) GetSlotFor(node string) adSlot
type PerformanceLevel ¶ added in v1.5.0
type PerformanceLevel string
type PerformanceLevelDesc ¶ added in v1.5.0
type PerformanceLevelDesc struct {
Size SizeRange
}
type QueryResponse ¶ added in v1.0.4
type QueryResponse struct {
// contains filtered or unexported fields
}
QueryResponse response struct for query server
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 SizeRange ¶ added in v1.5.0
func GetSizeRange ¶ added in v1.5.0
func GetSizeRange(category Category, pl PerformanceLevel) SizeRange