controller

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2021 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package controller provides CSI specification compatible controller service.

Index

Constants

View Source
const (
	// MinVolumeSizeBytes is minimal size for volume creation on PowerStore
	MinVolumeSizeBytes = 1048576
	// MaxVolumeSizeBytes is maximum size for volume creation on PowerStore
	MaxVolumeSizeBytes = 1099511627776 * 256 // 256 TB
	// VolumeSizeMultiple multiplier for volumes
	VolumeSizeMultiple = 8192
	// MaxVolumeNameLength max length for the volume name
	MaxVolumeNameLength = 128

	ErrUnknownAccessType = "unknown access type is not Block or Mount"
	ErrUnknownAccessMode = "access mode cannot be UNKNOWN"
	ErrNoMultiNodeWriter = "multi-node with writer(s) only supported for block access type"

	KeyFsType                  = "csi.storage.k8s.io/fstype"
	KeyFsTypeOld               = "FsType"
	KeyReplicationEnabled      = "isReplicationEnabled"
	KeyReplicationRPO          = "rpo"
	KeyReplicationRemoteSystem = "remoteSystem"
	KeyNasName                 = "nasName"
)
View Source
const (
	// These are available when enabling --extra-create-metadata for the external-provisioner.
	CSIPersistentVolumeName           = "csi.storage.k8s.io/pv/name"
	CSIPersistentVolumeClaimName      = "csi.storage.k8s.io/pvc/name"
	CSIPersistentVolumeClaimNamespace = "csi.storage.k8s.io/pvc/namespace"
	// These map to the above fields in the form of HTTP header names.
	HeaderPersistentVolumeName           = "x-csi-pv-name"
	HeaderPersistentVolumeClaimName      = "x-csi-pv-claimname"
	HeaderPersistentVolumeClaimNamespace = "x-csi-pv-namespace"
)

Extra metadata field names for propagating to gopowerstore and beyond.

View Source
const (
	// ReservedSize number of bytes reserved by creation of FS
	ReservedSize = 1610612736
)

Variables

This section is empty.

Functions

func EnsureProtectionPolicyExists added in v1.4.0

func EnsureProtectionPolicyExists(ctx context.Context, arr *array.PowerStoreArray,
	vgName string, remoteSystemName string, rpoEnum gopowerstore.RPOEnum) (string, error)

func EnsureReplicationRuleExists added in v1.4.0

func EnsureReplicationRuleExists(ctx context.Context, arr *array.PowerStoreArray,
	vgName string, remoteSystemId string, rpoEnum gopowerstore.RPOEnum) (string, error)

Types

type ControllerInterface

ControllerInterface provides most important controller methods. This essentially serves as a wrapper for controller service that is used in ephemeral volumes.

type FilesystemSnapshot

type FilesystemSnapshot gopowerstore.FileSystem

FilesystemSnapshot represents snapshot of the FileSystem

func (FilesystemSnapshot) GetID

func (f FilesystemSnapshot) GetID() string

GetID returns ID of the snapshot

func (FilesystemSnapshot) GetSize

func (f FilesystemSnapshot) GetSize() int64

GetSize returns current size of the snapshot

func (FilesystemSnapshot) GetSourceID

func (f FilesystemSnapshot) GetSourceID() string

GetSourceID returns ID of the volume/fs that snapshot was created from

func (FilesystemSnapshot) GetType added in v1.4.0

func (f FilesystemSnapshot) GetType() SnapshotType

GetType returns type of general snapshot (either filesystem or block)

type GeneralSnapshot

type GeneralSnapshot interface {
	// GetID returns ID of the snapshot
	GetID() string
	// GetSourceID returns ID of the volume/fs that snapshot was created from
	GetSourceID() string
	// GetSize returns current size of the snapshot
	GetSize() int64
	// GetType returns type of general snapshot (either filesystem or block)
	GetType() SnapshotType
}

GeneralSnapshot is an interface for combining both Volume and FileSystem

type NfsCreator

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

NfsCreator implementation of VolumeCreator for NFS volumes

func (*NfsCreator) CheckIfAlreadyExists

func (*NfsCreator) CheckIfAlreadyExists(ctx context.Context, name string, sizeInBytes int64, client gopowerstore.Client) (*csi.Volume, error)

CheckIfAlreadyExists queries storage array if FileSystem with given name exists

func (*NfsCreator) CheckName

func (*NfsCreator) CheckName(ctx context.Context, name string) error

CheckName validates volume name

func (*NfsCreator) CheckSize

func (*NfsCreator) CheckSize(ctx context.Context, cr *csi.CapacityRange) (int64, error)

CheckSize validates that size is correct and returns size in bytes

func (*NfsCreator) Clone

func (*NfsCreator) Clone(ctx context.Context, volumeSource *csi.VolumeContentSource_VolumeSource,
	volumeName string, sizeInBytes int64, parameters map[string]string, client gopowerstore.Client) (*csi.Volume, error)

Clone creates a clone of a FileSystem

func (*NfsCreator) Create

Create creates new FileSystem on storage array

func (*NfsCreator) CreateVolumeFromSnapshot

func (*NfsCreator) CreateVolumeFromSnapshot(ctx context.Context, snapshotSource *csi.VolumeContentSource_SnapshotSource,
	volumeName string, sizeInBytes int64, parameters map[string]string, client gopowerstore.Client) (*csi.Volume, error)

CreateVolumeFromSnapshot create a FileSystem from an existing FileSystem snapshot.

type NfsPublisher

type NfsPublisher struct {
	// ExternalAccess used to set custom ip to be added to the NFS Export 'hosts' list
	ExternalAccess string
}

NfsPublisher implementation of VolumePublisher for NFS volumes

func (*NfsPublisher) CheckIfVolumeExists

func (n *NfsPublisher) CheckIfVolumeExists(ctx context.Context, client gopowerstore.Client, volID string) error

CheckIfVolumeExists queries storage array if FileSystem with given name exists

func (*NfsPublisher) Publish

Publish publishes FileSystem by adding host (node) to the NFS Export 'hosts' list

type NfsSnapshotter

type NfsSnapshotter struct {
}

NfsSnapshotter is a implementation of VolumeSnapshotter for NFS volumes

func (*NfsSnapshotter) Create

func (*NfsSnapshotter) Create(ctx context.Context, snapName string, sourceID string, client gopowerstore.Client) (gopowerstore.CreateResponse, error)

Create creates new snapshot of a given FileSystem

func (*NfsSnapshotter) GetExistingSnapshot

func (*NfsSnapshotter) GetExistingSnapshot(ctx context.Context, snapName string, client gopowerstore.Client) (GeneralSnapshot, error)

GetExistingSnapshot queries storage array if given snapshot of the FileSystem already exists

type SCSICreator

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

SCSICreator implementation of VolumeCreator for SCSI based (FC, iSCSI) volumes

func (*SCSICreator) CheckIfAlreadyExists

func (*SCSICreator) CheckIfAlreadyExists(ctx context.Context, name string, sizeInBytes int64, client gopowerstore.Client) (*csi.Volume, error)

CheckIfAlreadyExists queries storage array if Volume with given name exists

func (*SCSICreator) CheckName

func (*SCSICreator) CheckName(ctx context.Context, name string) error

CheckName validates volume name

func (*SCSICreator) CheckSize

func (*SCSICreator) CheckSize(ctx context.Context, cr *csi.CapacityRange) (int64, error)

CheckSize validates that size is correct and returns size in bytes

func (*SCSICreator) Clone

func (*SCSICreator) Clone(ctx context.Context, volumeSource *csi.VolumeContentSource_VolumeSource,
	volumeName string, sizeInBytes int64, parameters map[string]string, client gopowerstore.Client) (*csi.Volume, error)

Clone creates a clone of a Volume

func (*SCSICreator) Create

Create creates new block volume on storage array

func (*SCSICreator) CreateVolumeFromSnapshot

func (*SCSICreator) CreateVolumeFromSnapshot(ctx context.Context, snapshotSource *csi.VolumeContentSource_SnapshotSource,
	volumeName string, sizeInBytes int64, parameters map[string]string, client gopowerstore.Client) (*csi.Volume, error)

CreateVolumeFromSnapshot create a volume from an existing snapshot. The snapshotSource gives the SnapshotId which is the volume to be replicated.

type SCSIPublisher

type SCSIPublisher struct {
}

SCSIPublisher implementation of VolumePublisher for SCSI based (FC, iSCSI) volumes

func (*SCSIPublisher) CheckIfVolumeExists

func (s *SCSIPublisher) CheckIfVolumeExists(ctx context.Context, client gopowerstore.Client, volID string) error

CheckIfVolumeExists queries storage array if Volume with given name exists

func (*SCSIPublisher) Publish

Publish publishes Volume by attaching it to the host

type SCSISnapshotter

type SCSISnapshotter struct {
}

SCSISnapshotter is a implementation of VolumeSnapshotter for SCSI based (FC, iSCSI) volumes

func (*SCSISnapshotter) Create

func (*SCSISnapshotter) Create(ctx context.Context, snapName string, sourceID string, client gopowerstore.Client) (gopowerstore.CreateResponse, error)

Create creates new snapshot of a given Volume

func (*SCSISnapshotter) GetExistingSnapshot

func (*SCSISnapshotter) GetExistingSnapshot(ctx context.Context, snapName string, client gopowerstore.Client) (GeneralSnapshot, error)

GetExistingSnapshot queries storage array if given snapshot of the Volume already exists

type Service

type Service struct {
	Fs fs.FsInterface

	array.Locker
	// contains filtered or unexported fields
}

Service is a controller service that contains array connection information and implements ControllerServer API

func (*Service) ControllerExpandVolume

ControllerExpandVolume resizes Volume or FileSystem by increasing available volume capacity in the storage array.

func (*Service) ControllerGetCapabilities

ControllerGetCapabilities returns list of capabilities that are supported by the driver.

func (*Service) ControllerGetVolume added in v1.4.0

func (s *Service) ControllerGetVolume(ctx context.Context, request *csi.ControllerGetVolumeRequest) (*csi.ControllerGetVolumeResponse, error)

func (*Service) ControllerPublishVolume

ControllerPublishVolume prepares Volume/FileSystem to be consumed by node by attaching/allowing access to the host.

func (*Service) ControllerUnpublishVolume

ControllerUnpublishVolume prepares Volume/FileSystem to be deleted by unattaching/disabling access to the host.

func (*Service) CreateRemoteVolume added in v1.4.0

func (*Service) CreateSnapshot

CreateSnapshot creates a snapshot of the Volume or FileSystem.

func (*Service) CreateStorageProtectionGroup added in v1.4.0

func (*Service) CreateVolume

CreateVolume creates either FileSystem or Volume on storage array.

func (*Service) DeleteSnapshot

DeleteSnapshot deletes a snapshot of the Volume or FileSystem.

func (*Service) DeleteStorageProtectionGroup added in v1.4.0

func (*Service) DeleteVolume

DeleteVolume deletes either FileSystem or Volume from storage array.

func (*Service) ExecuteAction added in v1.4.0

func (*Service) GetCapacity

func (s *Service) GetCapacity(ctx context.Context, req *csi.GetCapacityRequest) (*csi.GetCapacityResponse, error)

GetCapacity returns available capacity for a storage array.

func (*Service) GetReplicationCapabilities added in v1.4.0

func (*Service) GetStorageProtectionGroupStatus added in v1.4.0

func (*Service) Init

func (s *Service) Init() error

Init is a method that initializes internal variables of controller service

func (*Service) ListSnapshots

ListSnapshots list all accessible snapshots from the storage array.

func (*Service) ListVolumes

func (s *Service) ListVolumes(ctx context.Context, req *csi.ListVolumesRequest) (*csi.ListVolumesResponse, error)

ListVolumes returns all accessible volumes from the storage array.

func (*Service) ProbeController added in v1.4.0

func (*Service) RegisterAdditionalServers added in v1.4.0

func (s *Service) RegisterAdditionalServers(server *grpc.Server)

RegisterAdditionalServers registers replication extension

func (*Service) ValidateVolumeCapabilities

ValidateVolumeCapabilities checks if capabilities found in request are supported by driver.

type SnapshotType added in v1.4.0

type SnapshotType string
const (
	FilesystemSnapshotType SnapshotType = "filesystem"
	BlockSnapshotType      SnapshotType = "block"
)

type VolumeCreator

type VolumeCreator interface {
	// CheckSize validates that size is correct and returns size in bytes
	CheckSize(ctx context.Context, cr *csi.CapacityRange) (int64, error)
	// CheckName validates volume name
	CheckName(ctx context.Context, name string) error
	// CheckIfAlreadyExists queries storage array if given volume already exists
	CheckIfAlreadyExists(ctx context.Context, name string,
		sizeInBytes int64, client gopowerstore.Client) (*csi.Volume, error)
	// Create creates new volume
	Create(ctx context.Context, req *csi.CreateVolumeRequest, sizeInBytes int64,
		client gopowerstore.Client) (gopowerstore.CreateResponse, error)
	// Create volume from snapshot
	CreateVolumeFromSnapshot(ctx context.Context, snapshotSource *csi.VolumeContentSource_SnapshotSource,
		volumeName string, sizeInBytes int64, parameters map[string]string, client gopowerstore.Client) (*csi.Volume, error)
	// Create a volume from another volume
	Clone(ctx context.Context, volumeSource *csi.VolumeContentSource_VolumeSource, volumeName string, sizeInBytes int64, parameters map[string]string, client gopowerstore.Client) (*csi.Volume, error)
}

VolumeCreator allows to call Create and similar operations used in CreateVolume call

type VolumePublisher

type VolumePublisher interface {
	// CheckIfVolumeExists queries storage array if given volume already exists
	CheckIfVolumeExists(ctx context.Context, client gopowerstore.Client, volID string) error
	// Publish does the steps necessary for volume to be available on the node
	Publish(ctx context.Context, req *csi.ControllerPublishVolumeRequest, client gopowerstore.Client,
		kubeNodeID string, volumeID string) (*csi.ControllerPublishVolumeResponse, error)
}

VolumePublisher allows to publish a volume

type VolumeSnapshot

type VolumeSnapshot gopowerstore.Volume

VolumeSnapshot represents snapshot of the block Volume

func (VolumeSnapshot) GetID

func (v VolumeSnapshot) GetID() string

GetID returns ID of the snapshot

func (VolumeSnapshot) GetSize

func (v VolumeSnapshot) GetSize() int64

GetSize returns current size of the snapshot

func (VolumeSnapshot) GetSourceID

func (v VolumeSnapshot) GetSourceID() string

GetSourceID returns ID of the volume/fs that snapshot was created from

func (VolumeSnapshot) GetType added in v1.4.0

func (v VolumeSnapshot) GetType() SnapshotType

GetType returns type of general snapshot (either filesystem or block)

type VolumeSnapshotter

type VolumeSnapshotter interface {
	// GetExistingSnapshot queries storage array if given snapshot already exists
	GetExistingSnapshot(context.Context, string, gopowerstore.Client) (GeneralSnapshot, error)
	// Create creates new snapshot of a given volume
	Create(context.Context, string, string, gopowerstore.Client) (gopowerstore.CreateResponse, error)
}

VolumeSnapshotter allow to create snapshot of the volume/fs

Jump to

Keyboard shortcuts

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