driver

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2024 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinVolumeSizeBytes = 10 << 30 // 10GiB
	True               = "true"
)

MinVolumeSizeBytes is the smallest allowed size for a Linode block storage Volume, in bytes.

The CSI RPC scheme deal with bytes, whereas the Linode API's block storage volume endpoints deal with "GB". Internally, the driver will deal with sizes and capacities in bytes, but convert to and from "GB" when interacting with the Linode API.

View Source
const (
	// WaitTimeout is the default timeout duration used for polling the Linode
	// API, when waiting for a volume to enter an "active" state.
	WaitTimeout = 5 * time.Minute

	// CloneTimeout is the duration to wait when cloning a volume through the
	// Linode API.
	CloneTimeout = 15 * time.Minute
)
View Source
const (
	// VolumeTags is the parameter key used for passing a comma-separated list
	// of tags to the Linode API.
	VolumeTags = Name + "/volumeTags"

	// PublishInfoVolumeName is used to pass the name of the volume as it exists
	// in the Linode API (the "label") to [NodeStageVolume] and
	// [NodePublishVolume].
	PublishInfoVolumeName = Name + "/volume-name"

	// VolumeTopologyRegion is the parameter key used to indicate the region
	// the volume exists in.
	VolumeTopologyRegion string = "topology.linode.com/region"
)
View Source
const (
	// LuksEncryptedAttribute is used to pass the information if the volume should be
	// encrypted with luks to `NodeStageVolume`
	LuksEncryptedAttribute = Name + "/luks-encrypted"

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

	// LuksKeySizeAttribute is used to pass the information about the luks key size
	// to `NodeStageVolume`
	LuksKeySizeAttribute = Name + "/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 LinodeIDPath = "/linode-info/linode-id"

LinodeIDPath is the path to a file containing only the ID of the Linode instance the CSI node plugin is currently running on. This file is expected to be placed into the Linode by the init container provided with the CSI node plugin.

View Source
const MaxVolumeLabelPrefixLength = 12

MaxVolumeLabelPrefixLength is the maximum allowed length of a volume label prefix.

View Source
const Name = "linodebs.csi.linode.com"

Name is the name of the driver provided by this package. It is also used as the name of the socket file used for container orchestrator and driver communications.

Variables

View Source
var NewMetadataClient = func(ctx context.Context) (MetadataClient, error) {
	return metadata.NewClient(ctx)
}

Functions

func ControllerServiceCapabilities

func ControllerServiceCapabilities() []*csi.ControllerServiceCapability

ControllerServiceCapabilities returns the list of capabilities supported by this driver's controller service.

func NodeServiceCapabilities

func NodeServiceCapabilities() []*csi.NodeServiceCapability

NodeServiceCapabilities returns the list of capabilities supported by this driver's node service.

func VolumeCapabilityAccessModes

func VolumeCapabilityAccessModes() []*csi.VolumeCapability_AccessMode

VolumeCapabilityAccessModes returns the allowed access modes for a volume created by the driver.

Types

type ControllerServer added in v0.8.4

type ControllerServer struct {
	csi.UnimplementedControllerServer
	// contains filtered or unexported fields
}

func NewControllerServer

func NewControllerServer(ctx context.Context, driver *LinodeDriver, client linodeclient.LinodeClient, metadata Metadata) (*ControllerServer, error)

NewControllerServer instantiates a new RPC service that implements the CSI Controller Service RPC endpoints.

If driver or client are nil, NewControllerServer returns a non-nil error.

func (*ControllerServer) ControllerExpandVolume added in v0.8.4

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

ControllerExpandVolume resizes a volume to the specified capacity. It checks if the requested size is valid, ensures the volume exists, and performs the resize operation. If the volume is successfully resized, it returns the new capacity and indicates that no node expansion is required. For more details, refer to the CSI Driver Spec documentation.

func (*ControllerServer) ControllerGetCapabilities added in v0.8.4

ControllerGetCapabilities retrieves the capabilities supported by the controller service implemented by this Plugin. It returns a response containing the capabilities available for the CSI driver. For more details, refer to the CSI Driver Spec documentation.

func (*ControllerServer) ControllerPublishVolume added in v0.8.4

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

ControllerPublishVolume attaches a volume to a specified node. It ensures the volume is not already attached to another node and that the node can accommodate the attachment. Returns the device path if successful. For more details, refer to the CSI Driver Spec documentation.

func (*ControllerServer) ControllerUnpublishVolume added in v0.8.4

ControllerUnpublishVolume detaches a specified volume from a node. It checks if the volume is currently attached to the node and, if so, proceeds to detach it. The operation is idempotent, meaning it can be called multiple times without adverse effects. If the volume is not found or is already detached, it will return a successful response without error. For more details, refer to the CSI Driver Spec documentation.

func (*ControllerServer) CreateVolume added in v0.8.4

CreateVolume provisions a new volume on behalf of a user, which can be used as a block device or mounted filesystem. This operation is idempotent, meaning multiple calls with the same parameters will not create duplicate volumes. For more details, refer to the CSI Driver Spec documentation.

func (*ControllerServer) DeleteVolume added in v0.8.4

DeleteVolume removes the specified volume. This operation is idempotent, meaning that calling it multiple times with the same volume ID will have the same effect as calling it once. If the volume does not exist, the function will return a success response without any error. For more details, refer to the CSI Driver Spec documentation.

func (*ControllerServer) ListVolumes added in v0.8.4

ListVolumes returns a list of all volumes known to the provider, including their IDs, sizes, and accessibility information. It supports pagination through the starting token and maximum entries parameters as specified in the CSI Driver Spec. For more details, refer to the CSI Driver Spec documentation.

func (*ControllerServer) ValidateVolumeCapabilities added in v0.8.4

ValidateVolumeCapabilities checks if the requested volume capabilities are supported by the volume. It returns a confirmation response if the capabilities are valid, or an error if the volume does not exist or if no capabilities were provided. Refer to the @CSI Driver Spec for more details.

type Encryption added in v0.8.4

type Encryption struct {
	Exec       mountmanager.Executor
	FileSystem filesystem.FileSystem
	CryptSetup cryptsetupclient.CryptSetupClient
}

func NewLuksEncryption added in v0.8.4

func NewLuksEncryption(executor mountmanager.Executor, fileSystem filesystem.FileSystem, cryptSetup cryptsetupclient.CryptSetupClient) Encryption

type IdentityServer added in v0.8.4

type IdentityServer struct {
	csi.UnimplementedIdentityServer
	// contains filtered or unexported fields
}

IdentityServer implements the CSI Identity service for the Linode Block Storage CSI Driver.

func NewIdentityServer

func NewIdentityServer(ctx context.Context, linodeDriver *LinodeDriver) (*IdentityServer, error)

NewIdentityServer creates and initializes a new IdentityServer. It takes a context and a LinodeDriver as input and returns a pointer to IdentityServer and an error.

func (*IdentityServer) GetPluginCapabilities added in v0.8.4

func (linodeIdentity *IdentityServer) GetPluginCapabilities(ctx context.Context, req *csi.GetPluginCapabilitiesRequest) (*csi.GetPluginCapabilitiesResponse, error)

GetPluginCapabilities returns the capabilities of the CSI plugin. This method is REQUIRED for the Identity service as per the CSI spec. It informs the CO of the supported features by this plugin.

func (*IdentityServer) GetPluginInfo added in v0.8.4

func (linodeIdentity *IdentityServer) GetPluginInfo(ctx context.Context, req *csi.GetPluginInfoRequest) (*csi.GetPluginInfoResponse, error)

GetPluginInfo returns information about the CSI plugin. This method is REQUIRED for the Identity service as per the CSI spec. It returns the name and version of the CSI plugin.

func (*IdentityServer) Probe added in v0.8.4

func (linodeIdentity *IdentityServer) Probe(ctx context.Context, req *csi.ProbeRequest) (*csi.ProbeResponse, error)

Probe checks if the plugin is ready to serve requests. This method is REQUIRED for the Identity service as per the CSI spec. It allows the CO to check the readiness of the plugin.

type LinodeDriver

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

func GetLinodeDriver

func GetLinodeDriver(ctx context.Context) *LinodeDriver

func (*LinodeDriver) Run

func (linodeDriver *LinodeDriver) Run(ctx context.Context, endpoint string)

func (*LinodeDriver) SetupLinodeDriver

func (linodeDriver *LinodeDriver) SetupLinodeDriver(
	ctx context.Context,
	linodeClient linodeclient.LinodeClient,
	mounter *mount.SafeFormatAndMount,
	deviceUtils devicemanager.DeviceUtils,
	metadata Metadata,
	name,
	vendorVersion,
	volumeLabelPrefix string,
	encrypt Encryption,
) error

func (*LinodeDriver) ValidateControllerServiceRequest

func (linodeDriver *LinodeDriver) ValidateControllerServiceRequest(ctx context.Context, rpcType csi.ControllerServiceCapability_RPC_Type) error

type LuksContext

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

type Metadata

type Metadata struct {
	ID     int    // Instance ID.
	Label  string // The label assigned to the instance.
	Region string // Region the instance is running in.
	Memory uint   // Amount of memory the instance has, in bytes.
}

Metadata contains metadata about the node/instance the CSI node plugin is running on.

func GetMetadata

func GetMetadata(ctx context.Context, client MetadataClient) (Metadata, error)

GetMetadata retrieves information about the current node/instance from the Linode Metadata Service. If the Metadata Service is unavailable, or this function otherwise returns a non-nil error, callers should call GetMetadataFromAPI.

func GetMetadataFromAPI

func GetMetadataFromAPI(ctx context.Context, client linodeclient.LinodeClient, fs filesystem.FileSystem) (Metadata, error)

GetMetadataFromAPI attempts to retrieve metadata about the current node/instance directly from the Linode API.

func GetNodeMetadata added in v1.0.0

func GetNodeMetadata(ctx context.Context, cloudProvider linodeclient.LinodeClient, fileSystem filesystem.FileSystem) (Metadata, error)

GetNodeMetadata retrieves metadata about the current node/instance. It first attempts to use the Linode Metadata Service, and if that fails, it falls back to using the Linode API. This function ensures that valid metadata is obtained before returning.

type MetadataClient added in v1.0.0

type MetadataClient interface {
	GetInstance(ctx context.Context) (*metadata.InstanceData, error)
}

type NodeServer added in v0.8.4

type NodeServer struct {
	csi.UnimplementedNodeServer
	// contains filtered or unexported fields
}

func NewNodeServer

func NewNodeServer(ctx context.Context, linodeDriver *LinodeDriver, mounter *mount.SafeFormatAndMount, deviceUtils devicemanager.DeviceUtils, client linodeclient.LinodeClient, metadata Metadata, encrypt Encryption) (*NodeServer, error)

func (*NodeServer) NodeExpandVolume added in v0.8.4

func (*NodeServer) NodeGetCapabilities added in v0.8.4

func (*NodeServer) NodeGetInfo added in v0.8.4

func (*NodeServer) NodeGetVolumeStats added in v0.8.4

func (*NodeServer) NodePublishVolume added in v0.8.4

func (*NodeServer) NodeStageVolume added in v0.8.4

func (*NodeServer) NodeUnpublishVolume added in v0.8.4

func (*NodeServer) NodeUnstageVolume added in v0.8.4

type NonBlockingGRPCServer

type NonBlockingGRPCServer interface {
	// Start services at the endpoint
	Start(endpoint string, ids csi.IdentityServer, cs csi.ControllerServer, ns csi.NodeServer)
	// Waits for the service to stop
	Wait()
	// Stops the service gracefully
	Stop()
	// Stops the service forcefully
	ForceStop()
}

Defines Non blocking GRPC server interfaces

func NewNonBlockingGRPCServer

func NewNonBlockingGRPCServer() NonBlockingGRPCServer

type VolumeLifecycle

type VolumeLifecycle string

VolumeLifecycle is a type used to indicate the phase a volume is at when it is published and/or staged to a node.

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