disk

package
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2023 License: Apache-2.0 Imports: 61 Imported by: 0

Documentation

Index

Constants

View Source
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"
)
View Source
const (
	// BdfVolumeHang tag
	BdfVolumeHang = "BdfVolumeHang"
	// BdfVolumeUnUsed tag
	BdfVolumeUnUsed = "BdfVolumeUnUsed"
)
View Source
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"
	// SNAPSHOTFORCETAG tag
	SNAPSHOTFORCETAG = "forceDelete"
	// SNAPSHOTTAGKEY1 tag
	SNAPSHOTTAGKEY1 = "force.delete.snapshot.k8s.aliyun.com"
	// SNAPSHOTTYPE ...
	SNAPSHOTTYPE = "snapshotType"
	// INSTANTACCESS ...
	INSTANTACCESS = "InstantAccess"
	// RETENTIONDAYS ...
	RETENTIONDAYS = "retentionDays"
	// INSTANTACCESSRETENTIONDAYS ...
	INSTANTACCESSRETENTIONDAYS = "instantAccessRetentionDays"
	// SNAPSHOTRESOURCEGROUPID ...
	SNAPSHOTRESOURCEGROUPID = "resourceGroupId"
	// DiskSnapshotID means snapshot id
	DiskSnapshotID = "csi.alibabacloud.com/disk-snapshot-id"
	// VolumeSnapshotNamespace namespace
	VolumeSnapshotNamespace = "csi.storage.k8s.io/volumesnapshot/namespace"
	// VolumeSnapshotName tag
	VolumeSnapshotName = "csi.storage.k8s.io/volumesnapshot/name"
	// IAVolumeSnapshotKey tag
	IAVolumeSnapshotKey = "csi.alibabacloud.com/snapshot-ia"
	// SnapshotRequestTag interval limit
	SnapshotRequestTag = "SNAPSHOT_REQUEST_INTERVAL"
	// VolumeSnapshotContentName ...
	VolumeSnapshotContentName = "csi.storage.k8s.io/volumesnapshotcontent/name"
	// DefaultVolumeSnapshotClass ...
	DefaultVolumeSnapshotClass = "alibabacloud-disk-snapshot"

	// MultiAttach tag
	MultiAttach = "multiAttach"
	// MinimumDiskSizeInGB ...
	MinimumDiskSizeInGB = 20
	// MinimumDiskSizeInBytes ...
	MinimumDiskSizeInBytes = 21474836480

	// LastApplyKey key
	LastApplyKey = "kubectl.kubernetes.io/last-applied-configuration"
	// PvNameKey key
	PvNameKey = "csi.storage.k8s.io/pv/name"
	// PvcNameKey key
	PvcNameKey = "csi.storage.k8s.io/pvc/name"
	// PvcNamespaceKey key
	PvcNamespaceKey = "csi.storage.k8s.io/pvc/namespace"
	// StorageProvisionerKey key
	StorageProvisionerKey = "volume.beta.kubernetes.io/storage-provisioner"

	// KubernetesAlicloudDiskDriver driver name
	KubernetesAlicloudDiskDriver = "alicloud/disk"
	// MetadataURL metadata URL
	MetadataURL = "http://100.100.100.200/latest/meta-data/"
	// DocumentURL document URL
	DocumentURL = "http://100.100.100.200/latest/dynamic/instance-identity/document"
	// RegionIDTag region ID
	RegionIDTag = "region-id"
	// InstanceID instance ID
	InstanceID = "instance-id"
	// DiskConflict invalid operation type
	DiskConflict = "InvalidOperation.Conflict"
	// IncorrectDiskStatus incorrect disk status
	IncorrectDiskStatus = "IncorrectDiskStatus"
	// NeverAttached status belongs to IncorrectDiskStatus
	NeverAttached = "IncorrectDiskStatus.NeverAttached"
	// DiskCreatingSnapshot ...
	DiskCreatingSnapshot = "DiskCreatingSnapshot"
	// UserNotInTheWhiteList tag
	UserNotInTheWhiteList = "UserNotInTheWhiteList"
	// TagK8sPV tag
	TagK8sPV = "k8s-pv"
	// ZoneIDTag tag
	ZoneIDTag = "zone-id"
	// LogfilePrefix tag
	LogfilePrefix = "/var/log/alicloud/provisioner"
	// DiskNotAvailable tag
	DiskNotAvailable = "InvalidDataDiskCategory.NotSupported"
	// DiskNotAvailableVer2 tag
	DiskNotAvailableVer2 = "'DataDisk.n.Category' is not valid in this region."
	// DiskSizeNotAvailable tag
	DiskSizeNotAvailable = "InvalidDiskSize.NotSupported"
	// DiskPerformanceLevelNotMatch
	DiskPerformanceLevelNotMatch = "OperationDenied.PerformanceLevelNotMatch"
	// DiskLimitExceeded tag
	DiskLimitExceeded = "InstanceDiskLimitExceeded"
	// NotSupportDiskCategory tag
	NotSupportDiskCategory = "NotSupportDiskCategory"
	// DiskNotPortable tag
	DiskNotPortable = "DiskNotPortable"
	// DiskHighAvail tag
	DiskHighAvail = "available"
	// DiskCommon common disk type
	DiskCommon = "cloud"
	// DiskEfficiency efficiency disk type
	DiskEfficiency = "cloud_efficiency"
	// DiskSSD ssd disk type
	DiskSSD = "cloud_ssd"
	// DiskESSD essd disk type
	DiskESSD = "cloud_essd"
	// DiskESSDAuto  essd autopl disk type
	DiskESSDAuto = "cloud_auto"
	// DiskHighPerformance
	DiskPPerf = "cloud_pperf"
	// DiskStandPerformace
	DiskSPerf = "cloud_sperf"
	// DiskSharedSSD shared sdd disk type
	DiskSharedSSD = "san_ssd"
	// DiskSharedEfficiency shared efficiency disk type
	DiskSharedEfficiency = "san_efficiency"
	// MBSIZE tag
	MBSIZE = 1024 * 1024
	// GBSIZE tag
	GBSIZE = 1024 * MBSIZE
	// DefaultRegion is the default region id
	DefaultRegion = "cn-hangzhou"
	// DiskUUIDPath tag
	DiskUUIDPath = "/host/etc/kubernetes/volumes/disk/uuid"
	// ZoneID ...
	ZoneID = "zoneId"

	// NodeSchedueTag in annotations
	NodeSchedueTag = "volume.kubernetes.io/selected-node"
	// RetryMaxTimes ...
	RetryMaxTimes = 5

	// RemoteSnapshotLabelKey ...
	RemoteSnapshotLabelKey = "csi.alibabacloud.com/snapshot.targetregion"
	// SnapshotVolumeKey ...
	SnapshotVolumeKey = "csi.alibabacloud.com/snapshot.volumeid"

	VolumeDeleteAutoSnapshotKey                    = "csi.alibabacloud.com/volume-delete-autosnapshot-retentiondays"
	VOLUME_EXPAND_AUTO_SNAPSHOT_OP_KEY             = "volumeExpandAutoSnapshot"
	VOLUME_DELETE_AUTO_SNAPSHOT_OP_RETENT_DAYS_KEY = "volumeDeleteSnapshotRetentionDays"

	CSI_DEFAULT_FS_TYPE = "csi.storage.k8s.io/fstype"
	FS_TYPE             = "fsType"
	EXT4_FSTYPE         = "ext4"
	EXT3_FSTYPE         = "ext3"
	XFS_FSTYPE          = "xfs"

	DISK_PERFORMANCE_LEVEL0 = "PL0"
	DISK_PERFORMANCE_LEVEL1 = "PL1"
	DISK_PERFORMANCE_LEVEL2 = "PL2"
	DISK_PERFORMANCE_LEVEL3 = "PL3"

	SNAPSHOT_MAX_RETENTION_DAYS = 65536
	SNAPSHOT_MIN_RETENTION_DAYS = 1

	DISK_CLOUD_EFFICIENT_MIN_CAPACITY    = 20
	DISK_CLOUD_SSD_MIN_CAPACITY          = 20
	DISK_CLOUD_ESSD_PL0_MIN_CAPACITY     = 40
	DISK_CLOUD_ESSD_PL1_MIN_CAPACITY     = 20
	DISK_CLOUD_ESSD_PL2_MIN_CAPACITY     = 461
	DISK_CLOUD_ESSD_PL3_MIN_CAPACITY     = 1261
	DISK_CLOUD_ESSD_PLX_MIN_CAPACITY     = 40
	DISK_CLOUD_ESSD_AUTO_PL_MIN_CAPACITY = 40
)
View Source
const (
	TopologyZoneKey         = "topology." + driverName + "/zone"
	TopologyMultiZonePrefix = TopologyZoneKey + "-"
)

PluginFolder defines the location of diskplugin

View Source
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 tag
	SharedEnable = "shared"
	// SysConfigTag tag
	SysConfigTag = "sysConfig"
	// MkfsOptions tag
	MkfsOptions = "mkfsOptions"
	// DiskTagedByPlugin tag
	DiskTagedByPlugin = "DISK_TAGED_BY_PLUGIN"
	// DiskMetricByPlugin tag
	DiskMetricByPlugin = "DISK_METRIC_BY_PLUGIN"
	// DiskDetachDisable tag
	DiskDetachDisable = "DISK_DETACH_DISABLE"
	// DiskBdfEnable tag
	DiskBdfEnable = "DISK_BDF_ENABLE"
	// DiskDetachBeforeDelete tag
	DiskDetachBeforeDelete = "DISK_DETACH_BEFORE_DELETE"
	// DiskAttachByController tag
	DiskAttachByController = "DISK_AD_CONTROLLER"
	// DiskForceDetached tag
	DiskForceDetached = "DISK_FORCE_DETACHED"
	// 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"
	// MixRunTimeMode support both runc and runv
	MixRunTimeMode = "runc-runv"
	// RunvRunTimeMode tag
	RunvRunTimeMode = "runv"
	// InputOutputErr tag
	InputOutputErr = "input/output error"
	// FileSystemLoseCapacityPercent is the env of container
	FileSystemLoseCapacityPercent = "FILE_SYSTEM_LOSE_PERCENT"
	// NsenterCmd run command on host
	NsenterCmd = "/nsenter --mount=/proc/1/ns/mnt"
	// 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"
	// SocketPath is path of connector sock
	SocketPath = "/host/etc/csi-tool/diskconnector.sock"
	// MaxVolumesPerNode define max ebs one node
	MaxVolumesPerNode = 15
	// NOUUID is xfs fs mount opts
	NOUUID = "nouuid"
	// NodeMultiZoneEnable Enable node multi-zone mode
	NodeMultiZoneEnable = "NODE_MULTI_ZONE_ENABLE"
)

Variables

View Source
var (
	// VERSION should be updated by hand at each release
	VERSION = "v1.14.6"
	// GITCOMMIT will be overwritten automatically by the build system
	GITCOMMIT = "HEAD"
	// KubernetesAlicloudIdentity is the system identity for ecs client request
	KubernetesAlicloudIdentity = fmt.Sprintf("Kubernetes.Alicloud/CsiProvision.Disk-%s", VERSION)
	// AvailableDiskTypes ...
	AvailableDiskTypes = []string{DiskCommon, DiskESSD, DiskEfficiency, DiskSSD, DiskSharedSSD, DiskSharedEfficiency, DiskPPerf, DiskSPerf, DiskESSDAuto}
	// CustomDiskTypes ...
	CustomDiskTypes       = map[string]int{DiskESSD: 0, DiskSSD: 1, DiskEfficiency: 2, DiskPPerf: 3, DiskSPerf: 4, DiskESSDAuto: 5}
	CustomDiskPerfermance = map[string]string{DISK_PERFORMANCE_LEVEL0: "", DISK_PERFORMANCE_LEVEL1: "", DISK_PERFORMANCE_LEVEL2: "", DISK_PERFORMANCE_LEVEL3: ""}
)
View Source
var (
	// BLOCKVOLUMEPREFIX block volume mount prefix
	BLOCKVOLUMEPREFIX = filepath.Join(utils.KubeletRootDir, "/plugins/kubernetes.io/csi/volumeDevices/publish")
)
View Source
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",
}
View Source
var DingURL = os.Getenv("Ding_URL")

DingURL tag

View Source
var ObjReference = &v1.ObjectReference{
	Kind:      "BdfVolumeCheck",
	Name:      GlobalConfigVar.NodeID,
	UID:       "",
	Namespace: "",
}

ObjReference reference for bdf volume

View Source
var SnapshotRequestInterval = int64(10)

SnapshotRequestInterval snapshot request limit

View Source
var SnapshotRequestMap = map[string]int64{}

SnapshotRequestMap snapshot request limit

Functions

func BdfHealthCheck added in v1.1.4

func BdfHealthCheck()

BdfHealthCheck check bdf volume

func ChooseDevice added in v1.1.7

func ChooseDevice(rootDevice, subDevice string) string

func DescribeDiskInstanceEvents added in v1.1.7

func DescribeDiskInstanceEvents(instanceId string, ecsClient *ecs.Client) (eventMaps map[string]string, err error)

func DingTalk added in v1.1.4

func DingTalk(msg string)

DingTalk tag

func ExecCheckOutput added in v1.0.5

func ExecCheckOutput(cmd string, args ...string) (io.Reader, error)

ExecCheckOutput check output

func FindLines added in v1.0.5

func FindLines(reader io.Reader, keyword string) []string

FindLines parse lines

func GetDeviceByBdf added in v1.0.5

func GetDeviceByBdf(bdf string, enLog bool) (device string, err error)

GetDeviceByBdf get device name by bdf

func GetDeviceByMntPoint added in v1.0.1

func GetDeviceByMntPoint(targetPath string) string

GetDeviceByMntPoint return the device info from given mount point

func GetDeviceByVolumeID added in v1.0.3

func GetDeviceByVolumeID(volumeID string) (devices []string, err error)

GetDeviceByVolumeID First try to find the device by serial If cannot find the device using the serial number, get device by volumeID, link file should be like: /dev/disk/by-id/virtio-wz9cu3ctp6aj1iagco4h -> ../../vdc

func GetDeviceMountNum

func GetDeviceMountNum(targetPath string) int

GetDeviceMountNum get the device mount number

func GetDiskFormat added in v1.1.3

func GetDiskFormat(disk string) (string, string, error)

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

func GetMetaData

func GetMetaData(resource string) string

GetMetaData get host regionid, zoneid

func GetRegionID added in v1.1.0

func GetRegionID() string

GetRegionID Get RegionID from Environment Variables or Metadata

func GetRootSubDevicePath added in v1.1.7

func GetRootSubDevicePath(deviceList []string) (rootDevicePath, subDevicePath string, err error)

GetRootSubDevicePath ...

func GetVolumeDeviceName added in v1.0.3

func GetVolumeDeviceName(diskID string) []string

GetVolumeDeviceName get device name

func GetVolumeIDByDevice added in v1.1.0

func GetVolumeIDByDevice(device string) (volumeID string, err error)

GetVolumeIDByDevice get volumeID by specific deivce name according to by-id dictionary

func GlobalConfigSet added in v1.0.3

func GlobalConfigSet(nodeID string) *restclient.Config

GlobalConfigSet set Global Config

func IohubSriovBind added in v1.0.5

func IohubSriovBind(bdf string) error

IohubSriovBind io hub bind

func IohubSriovUnbind added in v1.0.5

func IohubSriovUnbind(bdf string) error

IohubSriovUnbind io hub unbind

func IsDeviceNvme added in v1.1.7

func IsDeviceNvme(deviceName string) bool

IsDeviceNvme check device is nvme type or not;

func IsDeviceUsedOthers added in v1.0.1

func IsDeviceUsedOthers(deviceName, volumeID string) (bool, error)

IsDeviceUsedOthers check if the given device attached by other instance

func IsDirEmpty added in v1.0.1

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 IsNoSuchDeviceErr added in v1.0.5

func IsNoSuchDeviceErr(err error) bool

IsNoSuchDeviceErr nd device error

func IsVFNode added in v1.0.6

func IsVFNode() bool

IsVFNode returns whether the current node is vf

func NewControllerServer

func NewControllerServer(d *csicommon.CSIDriver, client *crd.Clientset) csi.ControllerServer

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, c *ecs.Client) 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 StopDiskOperationRetry(instanceId string, ecsClient *ecs.Client) bool

func UpdateNode added in v1.1.2

func UpdateNode(nodeID string, c *ecs.Client)

UpdateNode ...

func VirtioPciBind added in v1.0.5

func VirtioPciBind(bdf string) error

VirtioPciBind pci bind

func VirtioPciUnbind added in v1.0.5

func VirtioPciUnbind(bdf string) error

VirtioPciUnbind pci unbind

Types

type BdfAttachInfo added in v1.0.5

type BdfAttachInfo struct {
	Depend             bool   `json:"depend"`
	LastAttachedNodeID string `json:"last_attached_node_id"`
}

BdfAttachInfo type

type DISK added in v1.0.1

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

DISK the DISK object

func NewDriver

func NewDriver(nodeID, endpoint string, runAsController bool) *DISK

NewDriver create the identity/node/controller server and disk driver

func (*DISK) Run added in v1.0.1

func (disk *DISK) Run()

Run start a new NodeServer

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 DingMsg added in v1.1.4

type DingMsg struct {
	Mstype string   `json:"mstype"`
	Text   DingText `json:"text"`
}

DingMsg struct

type DingText added in v1.1.4

type DingText struct {
	Content string `json:"content"`
}

DingText struct

type GlobalConfig added in v1.0.3

type GlobalConfig struct {
	EcsClient             *ecs.Client
	Region                string
	NodeID                string
	ZoneID                string
	CanAttach             bool
	DiskTagEnable         bool
	AttachMutex           sync.RWMutex
	ADControllerEnable    bool
	DetachDisabled        bool
	MetricEnable          bool
	RunTimeClass          string
	DetachBeforeAttach    bool
	DetachBeforeDelete    bool
	DiskBdfEnable         bool
	ClientSet             *kubernetes.Clientset
	FilesystemLosePercent float64
	ClusterID             string
	DiskPartitionEnable   bool
	ControllerService     bool
	BdfHealthCheck        bool
	DiskMultiTenantEnable bool
	SnapClient            *snapClientset.Clientset
	NodeMultiZoneEnable   bool
	WaitBeforeAttach      bool
	AddonVMFatalEvents    []string
	RequestBaseInfo       map[string]string
	SnapshotBeforeDelete  bool
}

GlobalConfig save global values for plugin

var (
	GlobalConfigVar GlobalConfig
)

define global variable

type PatchStringValue added in v1.0.5

type PatchStringValue struct {
	Op    string      `json:"op"`
	Path  string      `json:"path"`
	Value interface{} `json:"value"`
}

PatchStringValue type

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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