csi

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2023 License: Apache-2.0 Imports: 46 Imported by: 0

Documentation

Overview

Copyright © 2021 Alibaba Group Holding Ltd.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright © 2021 Alibaba Group Holding Ltd.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	DefaultEndpoint                    string = "unix://tmp/csi.sock"
	DefaultDriverName                  string = "local.csi.aliyun.com"
	DefaultEphemeralVolumeDataFilePath string = "/var/lib/kubelet/open-local-volumes.json"
	// connection timeout
	DefaultConnectTimeout = 3
	// VolumeOperationAlreadyExists is message fmt returned to CO when there is another in-flight call on the given volumeID
	VolumeOperationAlreadyExists = "An operation with the given volume=%q is already in progress"

	// VgNameTag is the vg name tag
	VgNameTag = "vgName"
	// VolumeTypeTag is the pv type tag
	VolumeTypeTag = "volumeType"
	// PvTypeTag is the pv type tag
	PvTypeTag = "pvType"
	// FsTypeTag is the fs type tag
	FsTypeTag = "fsType"
	// LvmTypeTag is the lvm type tag
	LvmTypeTag = "lvmType"
	// NodeAffinity is the pv node schedule tag
	NodeAffinity = "nodeAffinity"
	// DefaultFs default fs
	DefaultFs = "ext4"
	// DefaultNodeAffinity default NodeAffinity
	DefaultNodeAffinity = "true"
	// LinearType linear type
	LinearType = "linear"
	// DirectTag is direct-assigned volume tag
	DirectTag = "direct"
	// StripingType striping type
	StripingType = "striping"
)
View Source
const RestoreFileName = ".local.restored"
View Source
const (
	VolumeOperationAlreadyExistsErrorMsg = "An operation with the given Volume %s already exists"
)

Variables

Functions

func GetNodeIP

func GetNodeIP(node *v1.Node, nodeID string) (net.IP, error)

GetNodeIP get node address

func NewFakeSafeMounter added in v0.6.0

func NewFakeSafeMounter(scripts ...testingexec.FakeAction) *mount.SafeFormatAndMount

NewFakeSafeMounter creates a mount.SafeFormatAndMount instance suitable for use in unit tests.

func ParseEndpoint added in v0.6.0

func ParseEndpoint(endpoint string) (string, string, error)

Types

type CSIPlugin

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

func NewDriver

func NewDriver(driverName, nodeID, endpoint string, opts ...Option) *CSIPlugin

func (CSIPlugin) ControllerExpandVolume added in v0.6.0

func (cs CSIPlugin) ControllerExpandVolume(ctx context.Context, req *csi.ControllerExpandVolumeRequest) (*csi.ControllerExpandVolumeResponse, error)

ControllerExpandVolume expand volume

func (CSIPlugin) ControllerGetCapabilities added in v0.6.0

func (cs CSIPlugin) ControllerGetCapabilities(ctx context.Context, req *csi.ControllerGetCapabilitiesRequest) (*csi.ControllerGetCapabilitiesResponse, error)

func (CSIPlugin) ControllerPublishVolume added in v0.6.0

func (cs CSIPlugin) ControllerPublishVolume(ctx context.Context, req *csi.ControllerPublishVolumeRequest) (*csi.ControllerPublishVolumeResponse, error)

func (CSIPlugin) ControllerUnpublishVolume added in v0.6.0

func (cs CSIPlugin) ControllerUnpublishVolume(ctx context.Context, req *csi.ControllerUnpublishVolumeRequest) (*csi.ControllerUnpublishVolumeResponse, error)

func (CSIPlugin) CreateSnapshot added in v0.6.0

func (cs CSIPlugin) CreateSnapshot(ctx context.Context, req *csi.CreateSnapshotRequest) (*csi.CreateSnapshotResponse, error)

CreateSnapshot create lvm snapshot 处理两类快照 只读快照 读写快照

func (CSIPlugin) CreateVolume added in v0.6.0

func (cs CSIPlugin) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest) (*csi.CreateVolumeResponse, error)

CreateVolume csi interface

func (CSIPlugin) DeleteSnapshot added in v0.6.0

func (cs CSIPlugin) DeleteSnapshot(ctx context.Context, req *csi.DeleteSnapshotRequest) (*csi.DeleteSnapshotResponse, error)

DeleteSnapshot delete lvm snapshot

func (CSIPlugin) DeleteVolume added in v0.6.0

func (cs CSIPlugin) DeleteVolume(ctx context.Context, req *csi.DeleteVolumeRequest) (*csi.DeleteVolumeResponse, error)

func (CSIPlugin) GetCapacity added in v0.6.0

func (cs CSIPlugin) GetCapacity(ctx context.Context, req *csi.GetCapacityRequest) (*csi.GetCapacityResponse, error)

func (*CSIPlugin) GetPluginCapabilities added in v0.6.0

GetPluginCapabilities returns available capabilities of the plugin

func (*CSIPlugin) GetPluginInfo added in v0.6.0

func (plugin *CSIPlugin) GetPluginInfo(ctx context.Context, req *csi.GetPluginInfoRequest) (*csi.GetPluginInfoResponse, error)

func (CSIPlugin) ListSnapshots added in v0.6.0

func (cs CSIPlugin) ListSnapshots(ctx context.Context, req *csi.ListSnapshotsRequest) (*csi.ListSnapshotsResponse, error)

func (CSIPlugin) ListVolumes added in v0.6.0

func (cs CSIPlugin) ListVolumes(ctx context.Context, req *csi.ListVolumesRequest) (*csi.ListVolumesResponse, error)

func (CSIPlugin) NodeExpandVolume added in v0.6.0

func (ns CSIPlugin) NodeExpandVolume(ctx context.Context, req *csi.NodeExpandVolumeRequest) (
	*csi.NodeExpandVolumeResponse, error)

called with args {VolumeId:yoda-7825af6f-ea0a-4047-8704-7576dfe8d201 VolumePath:/var/lib/kubelet/pods/2ba91d3a-1b97-4d72-9dd9-be98aebbfe62/volumes/kubernetes.io~csi/yoda-7825af6f-ea0a-4047-8704-7576dfe8d201/mount CapacityRange:required_bytes:21474836480 StagingTargetPath:/var/lib/kubelet/plugins/kubernetes.io/csi/pv/yoda-7825af6f-ea0a-4047-8704-7576dfe8d201/globalmount VolumeCapability:mount:<fs_type:"ext4" > access_mode:<mode:SINGLE_NODE_WRITER > XXX_NoUnkeyedLiteral:{} XXX_unrecognized:[] XXX_sizecache:0}

func (CSIPlugin) NodeGetCapabilities added in v0.6.0

func (ns CSIPlugin) NodeGetCapabilities(ctx context.Context, req *csi.NodeGetCapabilitiesRequest) (*csi.NodeGetCapabilitiesResponse, error)

func (CSIPlugin) NodeGetInfo added in v0.6.0

func (ns CSIPlugin) NodeGetInfo(ctx context.Context, req *csi.NodeGetInfoRequest) (*csi.NodeGetInfoResponse, error)

func (CSIPlugin) NodeGetVolumeStats added in v0.6.0

func (ns CSIPlugin) NodeGetVolumeStats(ctx context.Context, req *csi.NodeGetVolumeStatsRequest) (*csi.NodeGetVolumeStatsResponse, error)

NodeGetVolumeStats used for csi metrics

func (CSIPlugin) NodePublishVolume added in v0.6.0

func (ns CSIPlugin) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolumeRequest) (*csi.NodePublishVolumeResponse, error)

volume_id: yoda-70597cb6-c08b-4bbb-8d41-c4afcfa91866 staging_target_path: /var/lib/kubelet/plugins/kubernetes.io/csi/pv/yoda-70597cb6-c08b-4bbb-8d41-c4afcfa91866/globalmount target_path: /var/lib/kubelet/pods/2a7bbb9c-c915-4006-84d7-0e3ac9d8d70f/volumes/kubernetes.io~csi/yoda-70597cb6-c08b-4bbb-8d41-c4afcfa91866/mount

func (CSIPlugin) NodeStageVolume added in v0.6.0

func (ns CSIPlugin) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRequest) (*csi.NodeStageVolumeResponse, error)

func (CSIPlugin) NodeUnpublishVolume added in v0.6.0

func (ns CSIPlugin) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpublishVolumeRequest) (*csi.NodeUnpublishVolumeResponse, error)

func (CSIPlugin) NodeUnstageVolume added in v0.6.0

func (ns CSIPlugin) NodeUnstageVolume(ctx context.Context, req *csi.NodeUnstageVolumeRequest) (*csi.NodeUnstageVolumeResponse, error)

func (*CSIPlugin) Probe added in v0.6.0

func (plugin *CSIPlugin) Probe(ctx context.Context, req *csi.ProbeRequest) (*csi.ProbeResponse, error)

func (*CSIPlugin) Run

func (plugin *CSIPlugin) Run() error

func (*CSIPlugin) Stop added in v0.6.0

func (plugin *CSIPlugin) Stop()

func (CSIPlugin) ValidateVolumeCapabilities added in v0.6.0

func (cs CSIPlugin) ValidateVolumeCapabilities(ctx context.Context, req *csi.ValidateVolumeCapabilitiesRequest) (*csi.ValidateVolumeCapabilitiesResponse, error)

type FakeSafeMounter added in v0.6.0

type FakeSafeMounter struct {
	mount.FakeMounter
	testingexec.FakeExec
}

FakeSafeMounter implements a mount.Interface interface suitable for use in unit tests.

func (*FakeSafeMounter) IsLikelyNotMountPoint added in v0.6.0

func (f *FakeSafeMounter) IsLikelyNotMountPoint(file string) (bool, error)

IsLikelyNotMountPoint overrides mount.FakeMounter.IsLikelyNotMountPoint.

func (*FakeSafeMounter) Mount added in v0.6.0

func (f *FakeSafeMounter) Mount(source, target, fstype string, options []string) error

Mount overrides mount.FakeMounter.Mount.

type Idempotent added in v0.5.5

type Idempotent interface {
	// The CSI data types are generated using a protobuf.
	// The generated structures are guaranteed to implement the Stringer interface.
	// Example: https://github.com/container-storage-interface/spec/blob/master/lib/go/csi/csi.pb.go#L3508
	// We can use the generated string as the key of our internal inflight database of requests.
	String() string
}

Idempotent is the interface required to manage in flight requests.

type InFlight added in v0.5.5

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

InFlight is a struct used to manage in flight requests per volumeId.

func NewInFlight added in v0.5.5

func NewInFlight() *InFlight

NewInFlight instanciates a InFlight structures.

func (*InFlight) Delete added in v0.5.5

func (db *InFlight) Delete(key string)

Delete removes the entry from the inFlight entries map. It doesn't return anything, and will do nothing if the specified key doesn't exist.

func (*InFlight) Insert added in v0.5.5

func (db *InFlight) Insert(key string) bool

Insert inserts the entry to the current list of inflight request key is volumeId for node and req hash for controller . Returns false when the key already exists.

type OSTool added in v0.6.0

type OSTool interface {
	Remove(name string) error
	Stat(name string) (os.FileInfo, error)
	MkdirAll(path string, perm os.FileMode) error
	RunCommand(cmd string) (string, error)
	IsBlockDevice(fullPath string) (bool, error)
	MountBlock(source, target string, opts ...string) error
	EnsureBlock(target string) error
	CleanupMountPoint(mountPath string, mounter mountutils.Interface, extensiveMountPointCheck bool) error
	ResizeFS(devicePath string, deviceMountPath string) (bool, error)
}

func NewFakeOSTool added in v0.6.0

func NewFakeOSTool() OSTool

func NewOSTool added in v0.6.0

func NewOSTool() OSTool

type Option added in v0.6.0

type Option func(*driverOptions)

Option configures a Driver

func WithCgroupDriver added in v0.6.0

func WithCgroupDriver(cgroupDriver string) Option

func WithDriverMode added in v0.6.0

func WithDriverMode(mode string) Option

func WithExtenderSchedulerNames added in v0.6.0

func WithExtenderSchedulerNames(extenderSchedulerNames []string) Option

func WithFrameworkSchedulerNames added in v0.6.0

func WithFrameworkSchedulerNames(frameworkSchedulerNames []string) Option

func WithGrpcConnectionTimeout added in v0.6.0

func WithGrpcConnectionTimeout(grpcConnectionTimeout int) Option

func WithKubeClient added in v0.6.0

func WithKubeClient(kubeclient kubernetes.Interface) Option

func WithLocalClient added in v0.6.0

func WithLocalClient(localclient clientset.Interface) Option

func WithSnapshotClient added in v0.6.0

func WithSnapshotClient(snapclient snapshot.Interface) Option

func WithSysPath added in v0.6.0

func WithSysPath(sysPath string) Option

func WithUseNodeHostname added in v0.7.1

func WithUseNodeHostname(useNodeHostname bool) Option

type PVAllocatedInfo added in v0.6.0

type PVAllocatedInfo struct {
	VGName     string `json:"vgName"`
	DeviceName string `json:"deviceName"`
	VolumeType string `json:"volumeType"`
}

type PvcPodSchedulerMap added in v0.6.0

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

func (*PvcPodSchedulerMap) Add added in v0.6.0

func (infoMap *PvcPodSchedulerMap) Add(pvcNamespace, pvcName, schedulerName string)

func (*PvcPodSchedulerMap) Get added in v0.6.0

func (infoMap *PvcPodSchedulerMap) Get(pvcNamespace, pvcName string) string

func (*PvcPodSchedulerMap) Remove added in v0.6.0

func (infoMap *PvcPodSchedulerMap) Remove(pvcNamespace, pvcName string)

type SchedulerArch added in v0.6.0

type SchedulerArch string
var (
	SchedulerArchExtender  SchedulerArch = "extender"
	SchedulerArchFramework SchedulerArch = "scheduling-framework"
	SchedulerArchUnknown   SchedulerArch = "unknown"
)

type SchedulerArchMap added in v0.6.0

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

func (*SchedulerArchMap) Get added in v0.6.0

func (archMap *SchedulerArchMap) Get(schedulerName string) SchedulerArch

type Store added in v0.5.5

type Store interface {
	AddVolume(volumeID, device string) error
	DeleteVolume(volumeID string) error
	GetDevice(volumeID string) (string, bool)
}

func NewMockVolumeStore added in v0.6.0

func NewMockVolumeStore(dataFilePath string) Store

func NewVolumeStore added in v0.5.5

func NewVolumeStore(dataFilePath string) (Store, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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