controller

package
v2.10.0 Latest Latest
Warning

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

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

Documentation

Overview

Package controller provides CSI specification compatible controller service.

Package controller provides CSI specification compatible controller service.

Index

Constants

View Source
const (
	// MinVolumeSizeBytes is minimal size for volume creation on PowerStore
	MinVolumeSizeBytes = 1048576
	// MinFilesystemSizeBytes is minimal size for Filesystem creation on PowerStore - 1.5Gi
	MinFilesystemSizeBytes = 1610612736
	// 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 represents error message for unknown access type
	ErrUnknownAccessType = "unknown access type is not Block or Mount"
	// ErrUnknownAccessMode represents error message for unknown access mode
	ErrUnknownAccessMode = "access mode cannot be UNKNOWN"
	// ErrNoMultiNodeWriter represents error message for multi node access
	ErrNoMultiNodeWriter = "multi-node with writer(s) only supported for block access type"
	// KeyFsType represents key for Fs Type
	KeyFsType = "csi.storage.k8s.io/fstype"
	// KeyFsTypeOld represents old key for Fs Type
	KeyFsTypeOld = "FsType"
	// KeyReplicationEnabled represents key for replication enabled
	KeyReplicationEnabled = "isReplicationEnabled"
	// KeyReplicationRPO represents key for replication RPO
	KeyReplicationRPO = "rpo"
	// KeyReplicationRemoteSystem represents key for replication remote system
	KeyReplicationRemoteSystem = "remoteSystem"
	// KeyReplicationIgnoreNamespaces represents key for replication ignore namespaces
	KeyReplicationIgnoreNamespaces = "ignoreNamespaces"
	// KeyReplicationVGPrefix represents key for replication vg prefix
	KeyReplicationVGPrefix = "volumeGroupPrefix"
	// KeyNasName represents key for nas name
	KeyNasName = "nasName"
	// KeyCSIPVCNamespace represents key for csi pvc namespace
	KeyCSIPVCNamespace = "csi.storage.k8s.io/pvc/namespace"
	// KeyCSIPVCName represents key for csi pvc name
	KeyCSIPVCName = "csi.storage.k8s.io/pvc/name"
)
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
)
View Source
const StateReady = "Ready"

StateReady resembles ready state

Variables

This section is empty.

Functions

func EnsureProtectionPolicyExists

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

EnsureProtectionPolicyExists ensures protection policy exists

func EnsureReplicationRuleExists

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

EnsureReplicationRuleExists ensures replication rule exists

func ExecuteAction

func ExecuteAction(session *gopowerstore.ReplicationSession, pstoreClient gopowerstore.Client, action gopowerstore.ActionType, failoverParams *gopowerstore.FailoverParams) error

ExecuteAction validates current state of replication & executes provided action on RS

func GetServiceTag

func GetServiceTag(ctx context.Context, req *csi.CreateVolumeRequest, arr *array.PowerStoreArray, volID string, protocol string) string

GetServiceTag returns the service tag associated with an appliance

Types

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

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 Interface

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

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(_ context.Context, name string) error

CheckName validates volume name

func (*NfsCreator) CheckSize

func (*NfsCreator) CheckSize(_ context.Context, cr *csi.CapacityRange, isAutoRoundOffFsSizeEnabled bool) (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(_ context.Context, name string) error

CheckName validates volume name

func (*SCSICreator) CheckSize

func (*SCSICreator) CheckSize(_ context.Context, cr *csi.CapacityRange, _ bool) (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.Interface

	array.Locker

	K8sVisibilityAutoRegistration bool
	// 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

ControllerGetVolume fetch current information about a volume

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

CreateRemoteVolume creates replica of volume in remote cluster

func (*Service) CreateSnapshot

CreateSnapshot creates a snapshot of the Volume or FileSystem.

func (*Service) CreateStorageProtectionGroup

CreateStorageProtectionGroup creates storage protection group

func (*Service) CreateVolume

CreateVolume creates either FileSystem or Volume on storage array.

func (*Service) CreateVolumeGroupSnapshot

CreateVolumeGroupSnapshot creates volume group snapshot

func (*Service) DeleteLocalVolume added in v2.7.0

DeleteLocalVolume deletes a volume on the local storage array upon request from a remote replication controller.

func (*Service) DeleteSnapshot

DeleteSnapshot deletes a snapshot of the Volume or FileSystem.

func (*Service) DeleteStorageProtectionGroup

DeleteStorageProtectionGroup deletes storage protection group

func (*Service) DeleteVolume

DeleteVolume deletes either FileSystem or Volume from storage array.

func (*Service) ExecuteAction

ExecuteAction is a method to execute an action request

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

GetReplicationCapabilities is a getter for replication capabilities

func (*Service) GetStorageProtectionGroupStatus

GetStorageProtectionGroupStatus gets storage protection group status

func (*Service) Init

func (s *Service) Init() error

Init is a method that initializes internal variables of controller service

func (*Service) IsIOInProgress

func (s *Service) IsIOInProgress(ctx context.Context, volID string, arrayConfig *array.PowerStoreArray, protocol string) (err error)

IsIOInProgress function check the IO operation status on array

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

ProbeController probes the controller service

func (*Service) QueryArrayStatus

func (s *Service) QueryArrayStatus(ctx context.Context, url string) (bool, error)

QueryArrayStatus make API call to the specified url to retrieve connection status

func (*Service) RegisterAdditionalServers

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.

func (*Service) ValidateVolumeHostConnectivity

ValidateVolumeHostConnectivity menthod will be called by podmon sidecars to check host connectivity with array

func (*Service) WithRP

func (s *Service) WithRP(key string) string

WithRP appends Replication Prefix to provided string

type SnapshotType

type SnapshotType string

SnapshotType represents type of snapshot

const (
	// FilesystemSnapshotType represents filesystem snapshot type
	FilesystemSnapshotType SnapshotType = "filesystem"
	// BlockSnapshotType represents block snapshot type
	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, isAutoRoundOffFsSizeEnabled bool) (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

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