driver

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2021 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KB = 1 << (10 * iota)
	MB
	GB
	TB
)
View Source
const (
	// allowed size increments for SSDs
	SSDStepSizeGB = 1

	// allowed size increments for bulk disks
	BulkStepSizeGB = 100

	// PublishInfoVolumeName is used to pass the volume name from
	// `ControllerPublishVolume` to `NodeStageVolume or `NodePublishVolume`
	PublishInfoVolumeName = DriverName + "/volume-name"

	// Storage type of the volume, must be either "ssd" or "bulk"
	StorageTypeAttribute = DriverName + "/volume-type"
)
View Source
const (
	// LuksEncryptedAttribute is used to pass the information if the volume should be
	// encrypted with luks to `NodeStageVolume`
	LuksEncryptedAttribute = DriverName + "/luks-encrypted"

	// LuksCipherAttribute is used to pass the information about the luks encryption
	// cypher to `NodeStageVolume`
	LuksCipherAttribute = DriverName + "/luks-cipher"

	// LuksKeySizeAttribute is used to pass the information about the luks key size
	// to `NodeStageVolume`
	LuksKeySizeAttribute = DriverName + "/luks-key-size"

	// LuksKeyAttribute is the key of the luks key used in the map of secrets passed from the CO
	LuksKeyAttribute = "luksKey"
)
View Source
const (
	// DriverName defines the name that is used in Kubernetes and the
	// system for the canonical, official name of this plugin.
	DriverName = "csi.cloudscale.ch"
)

Variables

This section is empty.

Functions

func GetCommit

func GetCommit() string

GetCommit returns the current commit hash value, as inserted at build time.

func GetTreeState

func GetTreeState() string

GetTreeState returns the current state of git tree, either "clean" or "dirty".

func GetVersion

func GetVersion() string

When building any packages that import version, pass the build/install cmd ldflags like so:

go build -ldflags "-X github.com/cloudscale-ch/csi-cloudscale/driver.version=0.0.1"

GetVersion returns the current release version, as inserted at build time.

Types

type Driver

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

Driver implements the following CSI interfaces:

csi.IdentityServer
csi.ControllerServer
csi.NodeServer

func NewDriver

func NewDriver(ep, token, urlstr string) (*Driver, error)

NewDriver returns a CSI plugin that contains the necessary gRPC interfaces to interact with Kubernetes over unix domain sockets for managaing cloudscale.ch Volumes

func (*Driver) ControllerExpandVolume added in v1.1.0

ControllerExpandVolume is called from the resizer to increase the volume size.

func (*Driver) ControllerGetCapabilities

ControllerGetCapabilities returns the capabilities of the controller service.

func (*Driver) ControllerPublishVolume

ControllerPublishVolume attaches the given volume to the node

func (*Driver) ControllerUnpublishVolume

ControllerUnpublishVolume deattaches the given volume from the node

func (*Driver) CreateSnapshot

CreateSnapshot will be called by the CO to create a new snapshot from a source volume on behalf of a user.

func (*Driver) CreateVolume

func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest) (*csi.CreateVolumeResponse, error)

CreateVolume creates a new volume from the given request. The function is idempotent.

func (*Driver) DeleteSnapshot

DeleteSnapshost will be called by the CO to delete a snapshot.

func (*Driver) DeleteVolume

func (d *Driver) DeleteVolume(ctx context.Context, req *csi.DeleteVolumeRequest) (*csi.DeleteVolumeResponse, error)

DeleteVolume deletes the given volume. The function is idempotent.

func (*Driver) GetCapacity

func (d *Driver) GetCapacity(ctx context.Context, req *csi.GetCapacityRequest) (*csi.GetCapacityResponse, error)

GetCapacity returns the capacity of the storage pool

func (*Driver) GetPluginCapabilities

GetPluginCapabilities returns available capabilities of the plugin

func (*Driver) GetPluginInfo

func (d *Driver) GetPluginInfo(ctx context.Context, req *csi.GetPluginInfoRequest) (*csi.GetPluginInfoResponse, error)

GetPluginInfo returns metadata of the plugin

func (*Driver) ListSnapshots

func (d *Driver) ListSnapshots(ctx context.Context, req *csi.ListSnapshotsRequest) (*csi.ListSnapshotsResponse, error)

ListSnapshots returns the information about all snapshots on the storage system within the given parameters regardless of how they were created. ListSnapshots shold not list a snapshot that is being created but has not been cut successfully yet.

func (*Driver) ListVolumes

func (d *Driver) ListVolumes(ctx context.Context, req *csi.ListVolumesRequest) (*csi.ListVolumesResponse, error)

ListVolumes returns a list of all requested volumes

func (*Driver) NodeExpandVolume added in v1.1.0

func (*Driver) NodeGetCapabilities

NodeGetCapabilities returns the supported capabilities of the node server

func (*Driver) NodeGetInfo

func (d *Driver) NodeGetInfo(ctx context.Context, req *csi.NodeGetInfoRequest) (*csi.NodeGetInfoResponse, error)

NodeGetInfo returns the supported capabilities of the node server. This should eventually return the droplet ID if possible. This is used so the CO knows where to place the workload. The result of this function will be used by the CO in ControllerPublishVolume.

func (*Driver) NodeGetVolumeStats

NodeGetVolumeStats returns the volume capacity statistics available for the the given volume.

func (*Driver) NodePublishVolume

NodePublishVolume mounts the volume mounted to the staging path to the target path

func (*Driver) NodeStageVolume

NodeStageVolume mounts the volume to a staging path on the node. This is called by the CO before NodePublishVolume and is used to temporary mount the volume to a staging path. Once mounted, NodePublishVolume will make sure to mount it to the appropriate path

func (*Driver) NodeUnpublishVolume

NodeUnpublishVolume unmounts the volume from the target path

func (*Driver) NodeUnstageVolume

NodeUnstageVolume unstages the volume from the staging path

func (*Driver) Probe

func (d *Driver) Probe(ctx context.Context, req *csi.ProbeRequest) (*csi.ProbeResponse, error)

Probe returns the health and readiness of the plugin

func (*Driver) Run

func (d *Driver) Run() error

Run starts the CSI plugin by communication over the given endpoint

func (*Driver) Stop

func (d *Driver) Stop()

Stop stops the plugin

func (*Driver) ValidateVolumeCapabilities

ValidateVolumeCapabilities checks whether the volume capabilities requested are supported.

type LuksContext

type LuksContext struct {
	EncryptionEnabled bool
	EncryptionKey     string
	EncryptionCipher  string
	EncryptionKeySize string
	VolumeName        string
	VolumeLifecycle   VolumeLifecycle
}

type Mounter

type Mounter interface {
	// Format formats the source with the given filesystem type
	Format(source, fsType string, luksContext LuksContext) error

	// Mount mounts source to target with the given fstype and options.
	Mount(source, target, fsType string, luksContext LuksContext, options ...string) error

	// Unmount unmounts the given target
	Unmount(target string, luksContext LuksContext) error

	// IsFormatted checks whether the source device is formatted or not. It
	// returns true if the source device is already formatted.
	IsFormatted(source string, luksContext LuksContext) (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)

	// Used to find a path in /dev/disk/by-id with a serial that we have from
	// the cloudscale API.
	FinalizeVolumeAttachmentAndFindPath(logger *logrus.Entry, VolumeId string) (*string, error)
}

Mounter is responsible for formatting and mounting volumes

type VolumeLifecycle

type VolumeLifecycle string
const (
	VolumeLifecycleNodeStageVolume     VolumeLifecycle = "NodeStageVolume"
	VolumeLifecycleNodePublishVolume   VolumeLifecycle = "NodePublishVolume"
	VolumeLifecycleNodeUnstageVolume   VolumeLifecycle = "NodeUnstageVolume"
	VolumeLifecycleNodeUnpublishVolume VolumeLifecycle = "NodeUnpublishVolume"
)

Jump to

Keyboard shortcuts

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