Documentation
¶
Index ¶
- Constants
- Variables
- func AppendJSONData(dataFilePath string, appData map[string]string) error
- func CheckParameterValidate(inputs []string) bool
- func CheckQuotaPathValidate(kubeClient *kubernetes.Clientset, path string) error
- func ConnectorRun(cmd string) (string, error)
- func CreateDest(dest string) error
- func CreateDestInHost(dest string) error
- func DoMountInHost(mntCmd string) error
- func EnsureBlock(target string) error
- func Fsync(f *os.File) error
- func GetAllocateInfoJSONFromPod(pod *corev1.Pod) string
- func GetFileContent(fileName string) string
- func GetNodeAddr(client kubernetes.Interface, node string, port string) (string, error)
- func GetNodeIP(client kubernetes.Interface, nodeID string) (net.IP, error)
- func GetPodRunTime(req *csi.NodePublishVolumeRequest, clientSet *kubernetes.Clientset) (string, error)
- func GetPvNameFormPodMnt(mntPath string) string
- func GetRegionIDAndInstanceID(nodeName string) (string, string, error)
- func GetVGNameFromCsiPV(pv *corev1.PersistentVolume) string
- func IsBlockDevice(fullPath string) (bool, error)
- func IsDir(path string) bool
- func IsDirEmpty(name string) (bool, error)
- func IsDirTmpfs(path string) bool
- func IsFileExisting(filename string) bool
- func IsHostFileExist(path string) bool
- func IsKataInstall() bool
- func IsLikelyNotMountPoint(file string) (bool, error)
- func IsMounted(mountPath string) bool
- func IsMountedInHost(mountPath string) bool
- func IsPathAvailiable(path string) error
- func LoadJSONData(dataFileName string) (map[string]string, error)
- func MkdirAll(path string, mode fs.FileMode) error
- func MountBlock(source, target string, opts ...string) error
- func Ping(ipAddress string) (*ping.Statistics, error)
- func ReadJSONFile(file string) (map[string]string, error)
- func RemoveAll(deletePath string) error
- func Run(cmd string) (string, error)
- func RunTimeout(cmd string, timeout int) error
- func SetNodeAddrMap(key string, value string)
- func SetupCgroupPathFormatter(driver CgroupDriverType)
- func Umount(mountPath string) error
- func UmountInHost(mountPath 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, ...)
- type BindingInfo
- type CgroupDriverType
- type CommandRunFunc
- type MediaType
- type MountPoint
- type Mounter
- type NodeAntiAffinityWeight
- type PVAllocatedInfo
- type PVCAllocateInfo
- type PodPVCAllocateInfo
- type Result
- type StrategyType
- type UpdateStatus
- type VolumeType
Constants ¶
const ( Cgroupfs CgroupDriverType = "cgroupfs" Systemd CgroupDriverType = "systemd" KubeRootNameSystemd = "kubepods.slice/" KubeBurstableNameSystemd = "kubepods-burstable.slice/" KubeBesteffortNameSystemd = "kubepods-besteffort.slice/" KubeRootNameCgroupfs = "kubepods/" KubeBurstableNameCgroupfs = "burstable/" KubeBesteffortNameCgroupfs = "besteffort/" )
const ( Gi uint64 = 1024 * 1024 * 1024 Mi uint64 = 1024 * 1024 DefaultPort int32 = 23000 StrategyBinpack StrategyType = "binpack" StrategySpread StrategyType = "spread" ProvisionerName string = "local.csi.kubeservice.cn" // ServiceType tag ServiceType = "SERVICE_TYPE" // PluginService represents the csi-plugin type. PluginService = "local" // ProvisionerService represents the csi-provisioner type. ProvisionerService = "provisioner" EnvLogLevel = "LogLevel" LogPanic = "Panic" LogFatal = "Fatal" LogError = "Error" LogWarn = "Warn" LogInfo = "Info" LogDebug = "Debug" LogTrace = "Trace" KubernetesNodeIdentityKey = "kubernetes.io/hostname" VolumeTypeKey = "volumeType" VolumeFSTypeKey = "fsType" VolumeMediaType = "mediaType" VolumeFSTypeExt4 = "ext4" VolumeFSTypeExt3 = "ext3" VolumeFSTypeXFS = "xfs" VolumeIOPS = "iops" VolumeBPS = "bps" BPSReadFile = "blkio.throttle.read_bps_device" BPSWriteFile = "blkio.throttle.write_bps_device" IOPSReadFile = "blkio.throttle.read_iops_device" IOPSWriteFile = "blkio.throttle.write_iops_device" PVName = "csi.storage.k8s.io/pv/name" PVCName = "csi.storage.k8s.io/pvc/name" PVCNameSpace = "csi.storage.k8s.io/pvc/namespace" Ephemeral = "csi.storage.k8s.io/ephemeral" VGName = "vgName" MPName = "MountPoint" DeviceName = "Device" // VolumeType MUST BE case sensitive VolumeTypeMountPoint VolumeType = "MountPoint" VolumeTypeLVM VolumeType = "LVM" VolumeTypeDevice VolumeType = "Device" VolumeTypeQuota VolumeType = "Quota" VolumeTypeUnknown VolumeType = "Unknown" MediaTypeSSD MediaType = "ssd" MediaTypeHDD MediaType = "hdd" MediaTypeUnspecified MediaType = "Unspecified" // This annotation is added to a PVC that has been triggered by scheduler to // be dynamically provisioned. Its value is the name of the selected node. AnnoSelectedNode = "volume.kubernetes.io/selected-node" LabelReschduleTimestamp = "pod.oecp.io/reschdule-timestamp" EnvExpandSnapInterval = "Expand_Snapshot_Interval" EnvForceCreateVG = "Force_Create_VG" PendingWithoutScheduledFieldSelector = "status.phase=Pending,spec.nodeName=" TriggerPendingPodCycle = time.Second * 300 ParamSnapshotName = "yoda.io/snapshot-name" ParamSnapshotReadonly = "csi.kubeservice.cn/readonly" ParamSnapshotInitialSize = "csi.kubeservice.cn/snapshot-initial-size" ParamSnapshotThreshold = "csi.kubeservice.cn/snapshot-expansion-threshold" ParamSnapshotExpansionSize = "csi.kubeservice.cn/snapshot-expansion-size" ParamVGName = "vgName" ParamLVSize = "size" EnvSnapshotPrefix = "SNAPSHOT_PREFIX" DefaultSnapshotPrefix = "snap" DefaultSnapshotInitialSize = 4 * 1024 * 1024 * 1024 DefaultSnapshotThreshold = 0.5 DefaultSnapshotExpansionSize = 1 * 1024 * 1024 * 1024 Separator = "<:SEP:>" // lv tags Lvm2LVNameTag = "LVM2_LV_NAME" Lvm2LVSizeTag = "LVM2_LV_SIZE" Lvm2LVKernelMajorTag = "LVM2_LV_KERNEL_MAJOR" Lvm2LVKernelMinorTag = "LVM2_LV_KERNEL_MINOR" Lvm2LVAttrTag = "LVM2_LV_ATTR" Lvm2LVUuidTag = "LVM2_LV_UUID" Lvm2CopyPercentTag = "LVM2_COPY_PERCENT" Lvm2LVTagsTag = "LVM2_LV_TAGS" // vg tags Lvm2VGNameTag = "LVM2_VG_NAME" Lvm2VGSizeTag = "LVM2_VG_SIZE" Lvm2VGFreeTag = "LVM2_VG_FREE" Lvm2VGUuidTag = "LVM2_VG_UUID" Lvm2VGTagsTag = "LVM2_VG_TAGS" Lvm2PVCountTag = "LVM2_PV_COUNT" // pv tags Lvm2PVUuidTag = "LVM2_PV_UUID" Lvm2PVNameTag = "LVM2_PV_NAME" Lvm2PVSizeTag = "LVM2_PV_SIZE" Lvm2PVFreeTag = "LVM2_PV_FREE" Lvm2PVTagsTag = "LVM2_PV_TAGS" // EVENT EventCreateVGFailed = "CreateVGFailed" NsenterCmd = "nsenter --mount=/proc/1/ns/mnt --ipc=/proc/1/ns/ipc --net=/proc/1/ns/net --uts=/proc/1/ns/uts " /* record: PVC->VG mapper - update by schedulerFramework prebind - read by schedulerFramework eventHandlers onPodAdd/Update */ AnnotationPodPVCAllocatedNeedMigrateKey = "csi.kubeservice.cn/pod-pvc-migrate" /* record: vgName to PV - update by nsl controller - read by csi: nodeServer publishVolume */ AnnotationPVAllocatedInfoKey = "csi.kubeservice.cn/pv-allocated" )
const ( // RuncRunTimeTag tag RuncRunTimeTag = "runc" // RunvRunTimeTag tag RunvRunTimeTag = "runv" )
Variables ¶
var ( // Kubeconfig is the path to kubeconfig file Kubeconfig string // MasterURL is the url of kube-apiserver MasterURL string )
var ( ValidProvisionerNames = []string{ ProvisionerName, } ValidVolumeType = []VolumeType{ VolumeTypeMountPoint, VolumeTypeLVM, VolumeTypeDevice, VolumeTypeQuota, } SupportedFS = []string{VolumeFSTypeExt3, VolumeFSTypeExt4, VolumeFSTypeXFS} SchedulerStrategy = StrategyBinpack )
var ( // NodeAddrMap map for NodeID and its Address NodeAddrMap = map[string]string{} // NodeAddrMutex Mutex for NodeAddr map NodeAddrMutex sync.RWMutex )
var CgroupPathFormatter = cgroupPathFormatterInSystemd
default use Systemd cgroup path format
var KubeletRootDir = "/var/lib/kubelet"
KubeletRootDir kubelet root dir;
var MountPathWithTLS = "/tls"
MountPathWithTLS tls mount path;
Functions ¶
func AppendJSONData ¶
AppendJSONData append map data to json file.
func CheckParameterValidate ¶
CheckParameterValidate is check parameter validating in csi-plugin
func CheckQuotaPathValidate ¶
func CheckQuotaPathValidate(kubeClient *kubernetes.Clientset, path string) error
CheckQuotaPathValidate is check quota path validating in csi-plugin
func ConnectorRun ¶
ConnectorRun Run shell command with host connector host connector is daemon running in host.
func CreateDestInHost ¶
CreateDestInHost create host dest directory
func DoMountInHost ¶
func EnsureBlock ¶
func GetNodeAddr ¶
GetNodeAddr get node address
func GetPodRunTime ¶
func GetPodRunTime(req *csi.NodePublishVolumeRequest, clientSet *kubernetes.Clientset) (string, error)
GetPodRunTime Get Pod runtimeclass config Default as runc.
func GetPvNameFormPodMnt ¶
GetPvNameFormPodMnt get pv name
func GetRegionIDAndInstanceID ¶
GetRegionIDAndInstanceID get regionID and instanceID object
func GetVGNameFromCsiPV ¶
func GetVGNameFromCsiPV(pv *corev1.PersistentVolume) string
func IsBlockDevice ¶
IsBlockDevice checks if the given path is a block device
func IsDirEmpty ¶
IsDirEmpty return status of dir empty or not
func IsFileExisting ¶
IsFileExisting check file exist in volume driver or not
func IsHostFileExist ¶
IsHostFileExist is check host file is existing in lvm
func IsLikelyNotMountPoint ¶
IsLikelyNotMountPoint return status of mount point,this function fix IsMounted return 0 bug IsLikelyNotMountPoint determines if a directory is not a mountpoint. It is fast but not necessarily ALWAYS correct. If the path is in fact a bind mount from one part of a mount to another it will not be detected. It also can not distinguish between mountpoints and symbolic links. mkdir /tmp/a /tmp/b; mount --bind /tmp/a /tmp/b; IsLikelyNotMountPoint("/tmp/b") will return true. When in fact /tmp/b is a mount point. If this situation is of interest to you, don't use this function...
func IsMountedInHost ¶
IsMountedInHost return status of host mounted or not
func LoadJSONData ¶
LoadJSONData loads json info from specified json file
func MountBlock ¶
func Ping ¶
func Ping(ipAddress string) (*ping.Statistics, error)
Ping check network like shell ping command
func ReadJSONFile ¶
ReadJSONFile return a json object
func SetNodeAddrMap ¶
SetNodeAddrMap set map with mutex
func SetupCgroupPathFormatter ¶
func SetupCgroupPathFormatter(driver CgroupDriverType)
func WriteAndSyncFile ¶
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 ¶
WriteJSONFile save json data to file
func WriteMetricsInfo ¶
Types ¶
type BindingInfo ¶
type BindingInfo struct { // node is the name of selected node Node string `json:"node"` // path for mount point Disk string `json:"disk"` // VgName is the name of selected volume group VgName string `json:"vgName"` // Device is the name for raw block device: /dev/vdb Device string `json:"device"` // [lvm] or [disk] or [device] or [quota] VolumeType string `json:"volumeType"` // PersistentVolumeClaim is the metakey for pvc: {namespace}/{name} PersistentVolumeClaim string `json:"persistentVolumeClaim"` }
BindingInfo represents the pvc and disk/lvm mapping
type CgroupDriverType ¶
type CgroupDriverType string
func (CgroupDriverType) Validate ¶
func (c CgroupDriverType) Validate() bool
type CommandRunFunc ¶
CommandRunFunc define the run function in utils for ut
type MountPoint ¶
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.
func ListProcMounts ¶
func ListProcMounts() ([]MountPoint, error)
ListProcMounts is shared with NsEnterMounter
type Mounter ¶
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 // IsFormatted checks whether the source device is formatted or not. It // returns true if the source device is already formatted. IsFormatted(source string) (bool, error) // IsMounted checks whether the target path is a correct mount (i.e: // propagated). It returns true if it's mounted. An error is returned in // case of system errors or if it's mounted incorrectly. IsMounted(target string) (bool, error) IsNotMountPoint(file string) (bool, error) SafePathRemove(target string) error HasMountRefs(mountPath string, mountRefs []string) bool }
Mounter is responsible for formatting and mounting volumes
type NodeAntiAffinityWeight ¶
type NodeAntiAffinityWeight struct {
// contains filtered or unexported fields
}
func NewNodeAntiAffinityWeight ¶
func NewNodeAntiAffinityWeight() *NodeAntiAffinityWeight
func (*NodeAntiAffinityWeight) Get ¶
func (w *NodeAntiAffinityWeight) Get(volumeType VolumeType) int
func (*NodeAntiAffinityWeight) Items ¶
func (w *NodeAntiAffinityWeight) Items(copy bool) map[VolumeType]int
func (*NodeAntiAffinityWeight) Put ¶
func (w *NodeAntiAffinityWeight) Put(volumeType VolumeType, weight int)
type PVAllocatedInfo ¶
type PVAllocatedInfo struct { VGName string `json:"vgName"` DeviceName string `json:"deviceName"` VolumeType string `json:"volumeType"` }
func GetAllocatedInfoFromPVAnnotation ¶
func GetAllocatedInfoFromPVAnnotation(pv *corev1.PersistentVolume) (*PVAllocatedInfo, error)
type PVCAllocateInfo ¶
type PVCAllocateInfo struct { PVCName string `json:"pvcName"` PVCNameSpace string `json:"pvcNameSpace"` PVAllocatedInfo `json:",inline"` }
type PodPVCAllocateInfo ¶
type PodPVCAllocateInfo struct {
PvcAllocates map[string]PVCAllocateInfo `json:"pvcAllocates"`
}
func GetAllocateInfoFromPod ¶
func GetAllocateInfoFromPod(pod *corev1.Pod) (*PodPVCAllocateInfo, error)
type Result ¶
type Result struct { Status string `json:"status"` Message string `json:"message,omitempty"` Device string `json:"device,omitempty"` }
Result struct definition
type StrategyType ¶
type StrategyType string
type UpdateStatus ¶
type UpdateStatus string
var ( UpdateStatusPending UpdateStatus = "pending" UpdateStatusAccepted UpdateStatus = "accepted" UpdateStatusFailed UpdateStatus = "failed" )
type VolumeType ¶
type VolumeType string
func VolumeTypeFromString ¶
func VolumeTypeFromString(s string) (VolumeType, error)