service

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: 55 Imported by: 0

README

csi-powermax - service

This directory contains the CSI Driver source code

Unit Tests

Unit Tests exist for the CSI Driver. These tests do not modify the array or require a Kubernetes instance.

Running Unit Tests

To run these tests, from the root directory of the repository, run:

make unit-test

Integration Tests

Integration Tests exist for the CSI Driver. These tests do not require a Kubernetes instance but WILL MODIFY the array

Pre-requisites

Before running integration tests, examine the env.sh script in the root of the repository. Within that file, two variables are defined:

  • X_CSI_POWERMAX_USER
  • X_CSI_POWERMAX_PASSWORD

Either change those variables to match an existing user in Unisphere, or create a new user in Unisphere matching those credentials.

Running Integration Tests

To run these tests, from the root directory of the repository, run:

make integration-test

Documentation

Index

Constants

View Source
const (
	MiBSizeInBytes         = 1048576
	DefaultVolumeSizeBytes = 1073741824
	// MinVolumeSizeBytes - This is the minimum volume size in bytes. This is equal to
	// the number of bytes to create a volume which requires 1 cylinder less than
	// the number of bytes required for 50 MB
	MinVolumeSizeBytes = 51118080
	// MaxVolumeSizeBytes - This is the maximum volume size in bytes. This is equal to
	// the minimum number of bytes required to create a 65 TB volume on PowerMax arrays
	MaxVolumeSizeBytes = 70368745881600

	StoragePoolCacheDuration       = 4 * time.Hour
	MaxVolIdentifierLength         = 64
	MaxPortGroupIdentifierLength   = 64
	MaxClusterPrefixLength         = 3
	CSIPrefix                      = "csi"
	DeletionPrefix                 = "_DEL"
	CsiHostPrefix                  = "csi-node-"
	CsiMVPrefix                    = "csi-mv-"
	CsiNoSrpSGPrefix               = "csi-no-srp-sg-"
	CsiVolumePrefix                = "csi-"
	CsiRepSGPrefix                 = "csi-rep-sg-"
	PublishContextDeviceWWN        = "DEVICE_WWN"
	RemotePublishContextDeviceWWN  = "REMOTE_DEVICE_WWN"
	PublishContextLUNAddress       = "LUN_ADDRESS"
	RemotePublishContextLUNAddress = "REMOTE_LUN_ADDRESS"
	PortIdentifiers                = "PORT_IDENTIFIERS"
	RemotePortIdentifiers          = "REMOTE_PORT_IDENTIFIERS"
	PortIdentifierKeyCount         = "PORT_IDENTIFIER_KEYS"
	RemotePortIdentifierKeyCount   = "REMOTE_PORT_IDENTIFIER_KEYS"
	MaxPortIdentifierLength        = 128
	FCSuffix                       = "-FC"
	PGSuffix                       = "PG"

	IscsiTransportProtocol  = "ISCSI"
	FcTransportProtocol     = "FC"
	MaxSnapIdentifierLength = 32
	SnapDelPrefix           = "DEL"

	StorageGroup          = "StorageGroup"
	Async                 = "ASYNC"
	Sync                  = "SYNC"
	Metro                 = "METRO"
	ActiveBias            = "ActiveBias"
	Consistent            = "Consistent"
	Synchronized          = "Synchronized"
	FailedOver            = "Failed Over"
	Suspended             = "Suspended"
	Invalid               = "Invalid"
	Split                 = "Split"
	SyncInProgress        = "SyncInProg"
	Vsphere               = "VSPHERE"
	MigrationActionCommit = "Commit"
	HostLimitName         = "HostLimitName"
	HostLimits            = "hostLimits"
	HostIOLimitMBSec      = "HostIOLimitMBSec"
	HostIOLimitIOSec      = "HostIOLimitIOSec"
	DynamicDistribution   = "DynamicDistribution"
	NFS                   = "nfs"
	NASServerName         = "nasServer"
)

constants

View Source
const (
	SymmetrixIDParam  = "SYMID"
	ServiceLevelParam = "ServiceLevel"
	ContentSource     = "VolumeContentSource"
	StoragePoolParam  = "SRP"
	// If storage_group is set, this over-rides the generation of the Storage Group from SLO/SRP
	StorageGroupParam      = "StorageGroup"
	ThickVolumesParam      = "ThickVolumes" // "true" or "false" or "" (defaults thin)
	ApplicationPrefixParam = "ApplicationPrefix"
	CapacityGB             = "CapacityGB"

	// These params will be in replication enabled storage class
	RepEnabledParam              = "isReplicationEnabled"
	LocalRDFGroupParam           = "RdfGroup"
	RemoteRDFGroupParam          = "RemoteRDFGroup"
	RemoteSymIDParam             = "RemoteSYMID"
	RemoteVolumeIDParam          = "RemoteVolumeID"
	ReplicationModeParam         = "RdfMode"
	CSIPVCNamespace              = "csi.storage.k8s.io/pvc/namespace"
	CSIPersistentVolumeName      = "csi.storage.k8s.io/pv/name"
	CSIPersistentVolumeClaimName = "csi.storage.k8s.io/pvc/name"
	// 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"
	RemoteServiceLevelParam              = "RemoteServiceLevel"
	RemoteSRPParam                       = "RemoteSRP"
	BiasParam                            = "Bias"
	FsTypeParam                          = "csi.storage.k8s.io/fstype"
	AllowRootParam                       = "allowRoot"
)

Keys for parameters to CreateVolume

View Source
const (
	DeletionQueueLength    = 10000
	MaxRequestsPerStep     = 1000
	MaxErrorsStored        = 5
	MaxErrorCount          = 100
	CacheValidTime         = 30 * time.Minute
	MinPollingInterval     = 3 * time.Second
	WaitTillSyncInProgTime = 20 * time.Second

	FinalError = "Final error: Max error count reached, device will be removed from Deletion Queue"
)

Constants used by deletion worker

View Source
const (
	// EnvDriverName is the name of the enviroment variable used to set the
	// name of the driver
	EnvDriverName = "X_CSI_POWERMAX_DRIVER_NAME"
	// EnvEndpoint is the name of the enviroment variable used to set the
	// HTTP endpoint of Unisphere
	EnvEndpoint = "X_CSI_POWERMAX_ENDPOINT"

	// EnvUser is the name of the enviroment variable used to set the
	// username when authenticating to Unisphere
	EnvUser = "X_CSI_POWERMAX_USER"

	// EnvPassword is the name of the enviroment variable used to set the
	// user's password when authenticating to Unisphere
	// #nosec G101
	EnvPassword = "X_CSI_POWERMAX_PASSWORD" // #nosec G101

	// EnvSkipCertificateValidation is the name of the environment variable used
	// to specify Unisphere's certificate chain and host name should not
	// be validated.
	EnvSkipCertificateValidation = "X_CSI_POWERMAX_SKIP_CERTIFICATE_VALIDATION"

	// EnvNodeName is the name of the enviroment variable used to set the
	// hostname where the node service is running
	EnvNodeName = "X_CSI_POWERMAX_NODENAME"

	// EnvThick is the name of the enviroment variable used to specify
	// that thick provisioning should be used when creating volumes
	EnvThick = "X_CSI_POWERMAX_THICKPROVISIONING"

	// EnvAutoProbe is the name of the environment variable used to specify
	// that the controller service should automatically probe itself if it
	// receives incoming requests before having been probed, in direct
	// violation of the CSI spec
	EnvAutoProbe = "X_CSI_POWERMAX_AUTOPROBE" // #nosec 101

	// EnvPortGroups is the name of the environment variable that is used
	// to specifiy a list of Port Groups that the driver can choose from
	// These Port Groups must exist and be populated
	EnvPortGroups = "X_CSI_POWERMAX_PORTGROUPS"

	// EnvClusterPrefix is the name of the environment variable that is used
	// to specifiy a a prefix to apply to objects creaated via this CSI cluster
	EnvClusterPrefix = "X_CSI_K8S_CLUSTER_PREFIX" // #nosec 101

	// EnvISCSIChroot is the path to which the driver will chroot before
	// running any iscsi commands. This value should only be set when instructed
	// by technical support.
	EnvISCSIChroot = "X_CSI_ISCSI_CHROOT"

	// EnvGrpcMaxThreads is the configuration value of the maximum number of concurrent
	// grpc requests. This value should be an integer string.
	EnvGrpcMaxThreads = "X_CSI_GRPC_MAX_THREADS"

	// EnvEnableBlock enables block capabilities support.
	EnvEnableBlock = "X_CSI_ENABLE_BLOCK"

	// EnvPreferredTransportProtocol enables you to be able to force the transport protocol.
	// Valid values are "FC" or "ISCSI" or "". If "", will choose FC if both are available.
	// This is mainly for testing.
	EnvPreferredTransportProtocol = "X_CSI_TRANSPORT_PROTOCOL" // #nosec 101

	// EnvUnisphereProxyServiceName is the name of the proxy service in kubernetes
	// If set, then driver will attempt to read the associated env value
	// If set to none, then the driver will connect to Unisphere
	EnvUnisphereProxyServiceName = "X_CSI_POWERMAX_PROXY_SERVICE_NAME"

	// EnvSidecarProxyPort is the port on which the reverse proxy
	// server run, if run as a sidecar container
	EnvSidecarProxyPort = "X_CSI_POWERMAX_SIDECAR_PROXY_PORT"

	// EnvEnableCHAP is the flag which determines if the driver is going
	// to set the CHAP credentials in the ISCSI node database at the time
	// of node plugin boot
	EnvEnableCHAP = "X_CSI_POWERMAX_ISCSI_ENABLE_CHAP"

	// EnvISCSICHAPUserName is the username for the ISCSI CHAP
	// authentication for the host initiator(s)
	// If set to none, then the driver will use the ISCSI IQN as the username
	EnvISCSICHAPUserName = "X_CSI_POWERMAX_ISCSI_CHAP_USERNAME"

	// EnvISCSICHAPPassword is the password for the ISCSI CHAP
	// authentication for the host initiator(s)
	// #nosec G101
	EnvISCSICHAPPassword = "X_CSI_POWERMAX_ISCSI_CHAP_PASSWORD" // #nosec 101

	// EnvNodeNameTemplate is the templatized name to construct node names
	// by the driver based on a name format as specified by the user in this
	// variable
	EnvNodeNameTemplate = "X_CSI_IG_NODENAME_TEMPLATE"

	// EnvModifyHostName when this value is set to "true", the driver will
	// modify the existing host name to a new name as specified in the EnvNodeNameTemplate
	EnvModifyHostName = "X_CSI_IG_MODIFY_HOSTNAME" // #nosec 101

	// EnvReplicationContextPrefix enables sidecars to read required information from volume context
	EnvReplicationContextPrefix = "X_CSI_REPLICATION_CONTEXT_PREFIX"

	// EnvReplicationPrefix is used as a prefix to find out if replication is enabled
	EnvReplicationPrefix = "X_CSI_REPLICATION_PREFIX" // #nosec 101

	// EnvManagedArrays is an env variable with a list of space separated arrays.
	EnvManagedArrays = "X_CSI_MANAGED_ARRAYS"

	// EnvKubeConfigPath indicates kubernetes configuration that has to be used by CSI Driver
	EnvKubeConfigPath = "KUBECONFIG"

	// EnvConfigFilePath is an env variable which contains the full path for the config file
	EnvConfigFilePath = "X_CSI_POWERMAX_CONFIG_PATH"

	// EnvMaxVolumesPerNode specifies maximum number of volumes that controller can publish to the node.
	EnvMaxVolumesPerNode = "X_CSI_MAX_VOLUMES_PER_NODE"

	// EnvHealthMonitorEnabled is an env variable which indicated if volume health monitor is enabled
	EnvHealthMonitorEnabled = "X_CSI_HEALTH_MONITOR_ENABLED"

	// EnvTopoConfigFilePath is an env variable which contains the full path for topology config file
	EnvTopoConfigFilePath = "X_CSI_POWERMAX_TOPOLOGY_CONFIG_PATH"

	// EnvTopologyFilterEnabled is an env variable which indicates if volume health monitor is enabled
	EnvTopologyFilterEnabled = "X_CSI_TOPOLOGY_CONTROL_ENABLED"

	// EnvVSphereEnabled is an env variable which indicates if FC vsphere is enabled
	EnvVSphereEnabled = "X_CSI_VSPHERE_ENABLED"

	// EnvVSpherePortGroup is an env variable which has FC portGroup for vSphere
	EnvVSpherePortGroup = "X_CSI_VSPHERE_PORTGROUP"

	// EnvVSphereHostName is an env variable which has FC host for vSphere
	EnvVSphereHostName = "X_CSI_VSPHERE_HOSTNAME"

	// EnvVCHost is an env variable that has vCenter Host endpoint
	EnvVCHost = "X_CSI_VCENTER_HOST"

	// EnvVCUsername is an env variable that has vCenter username
	EnvVCUsername = "X_CSI_VCENTER_USERNAME"

	// EnvVCPassword is an env variable that has vCenter password
	EnvVCPassword = "X_CSI_VCENTER_PWD" // #nosec G101
)
View Source
const (
	Establish     = "Establish"
	Resume        = "Resume"
	Suspend       = "Suspend"
	FailOver      = "Failover"
	Swap          = "Swap"
	FailBack      = "Failback"
	Reprotect     = "Reprotect"
	QueryRemSymID = "remote_symmetrix_id"
	QueryAsync    = "Asynchronous"
	QuerySync     = "Synchronous"
	QueryMetro    = "Active"
)

Supported actions

View Source
const (
	Name            = "csi-powermax.dellemc.com"         // Name is the name of the CSI plug-in.
	ApplicationName = "CSI Driver for Dell EMC PowerMax" // ApplicationName is the name used to register with Powermax REST APIs

	CSILogLevelParam  = "CSI_LOG_LEVEL"
	CSILogFormatParam = "CSI_LOG_FORMAT"
)

Constants for the service

View Source
const (
	TempSnap       = "CSI_TEMP_SNAP"
	Defined        = "Defined"
	Link           = "Link"
	Unlink         = "Unlink"
	Rename         = "Rename"
	MaxUnlinkCount = 5
)

The follow constants are for internal use within the pmax library.

Variables

View Source
var Manifest = map[string]string{
	"url":    "http://github.com/dell/csi-powermax",
	"semver": core.SemVer,
	"commit": core.CommitSha32,
	"formed": core.CommitTime.Format(time.RFC1123),
}

Manifest is the SP's manifest.

Functions

func CleanupMapEntries

func CleanupMapEntries(duration time.Duration)

CleanupMapEntries - clean up stale entries from the map

func GetRDFInfoFromSGID

func GetRDFInfoFromSGID(storageGroupID string) (namespace string, rDFGno string, repMode string, err error)

GetRDFInfoFromSGID returns namespace , RDFG number and replication mode

func LocalRDFPortsNotAdded added in v2.4.0

func LocalRDFPortsNotAdded(createRDFPayload *types.RDFGroupCreate, localSymID string, dir string, port int) bool

LocalRDFPortsNotAdded checks if the RDF ports are already added to the create RDF payload and return accordingly.

func LockRequestHandler

func LockRequestHandler()

LockRequestHandler - goroutine which listens for any lock/unlock requests

func ReleaseLock

func ReleaseLock(resourceID string, requestID string, lockNum int)

ReleaseLock - Release a held lock for resourceID Input lockNum should be the same as one returned by RequestLock

func RequestLock

func RequestLock(resourceID string, requestID string) int

RequestLock - Request for lock for a given resource ID requestID is optional returns a lock number which is used later to release the lock

Types

type Device

type Device struct {
	FullPath string
	Name     string
	RealDev  string
}

Device is a struct for holding details about a block device

func GetDevice

func GetDevice(path string) (*Device, error)

GetDevice returns a Device struct with info about the given device, or an error if it doesn't exist or is not a block device

type FCTargetInfo

type FCTargetInfo struct {
	WWPN string
}

FCTargetInfo represents basic information about FC target

type ISCSITargetInfo

type ISCSITargetInfo struct {
	Portal string
	Target string
}

ISCSITargetInfo represents basic information about iSCSI target

type LockInfo

type LockInfo struct {
	LockRequests       chan LockRequestInfo
	CurrentLockNumber  int
	CurrentWaitChannel chan int
	Count              int
}

LockInfo - Stores information about each resource id in the map

type LockRequest

type LockRequest struct {
	ResourceID  string
	LockNumber  int
	Unlock      bool
	WaitChannel chan int
}

LockRequest - Input structure to specify a request for locking a resource

type LockRequestInfo

type LockRequestInfo struct {
	LockNumber  int
	WaitChannel chan int
}

LockRequestInfo - Stores information about each lock request

type NodeConfig added in v2.3.0

type NodeConfig struct {
	NodeName string   `yaml:"nodeName, omitempty"`
	Rules    []string `yaml:"rules, omitempty"`
}

NodeConfig defines rules for given node

type Opts

type Opts struct {
	Endpoint                   string
	UseProxy                   bool
	ProxyServiceHost           string
	ProxyServicePort           string
	User                       string
	Password                   string
	SystemName                 string
	NodeName                   string
	NodeFullName               string
	TransportProtocol          string
	DriverName                 string
	CHAPUserName               string
	CHAPPassword               string
	Insecure                   bool
	Thick                      bool
	AutoProbe                  bool
	EnableBlock                bool
	EnableCHAP                 bool
	PortGroups                 []string
	ClusterPrefix              string
	ManagedArrays              []string
	DisableCerts               bool   // used for unit testing only
	Lsmod                      string // used for unit testing only
	EnableSnapshotCGDelete     bool   // when snapshot deleted, enable deleting of all snaps in the CG of the snapshot
	EnableListVolumesSnapshots bool   // when listing volumes, include snapshots and volumes
	GrpcMaxThreads             int    // Maximum threads configured in grpc
	NonDefaultRetries          bool   // Indicates if non-default retry values to be used for deletion worker, only for unit testing
	NodeNameTemplate           string
	ModifyHostName             bool
	ReplicationContextPrefix   string // Enables sidecars to read required information from volume context
	ReplicationPrefix          string // Used as a prefix to find out if replication is enabled
	IsHealthMonitorEnabled     bool   // used to check if health monitor for volume is enabled
	IsTopologyControlEnabled   bool   // used to filter topology keys based on user config
	IsVsphereEnabled           bool   // used to check if vSphere is enabled
	VSpherePortGroup           string // port group for vsphere
	VSphereHostName            string // host (initiator group) for vsphere
	VCenterHostURL             string // vCenter host url
	VCenterHostUserName        string // vCenter host username
	VCenterHostPassword        string // vCenter password
	MaxVolumesPerNode          int64  // to specify volume limits
	KubeConfigPath             string // to specify k8s configuration to be used CSI driver
}

Opts defines service configuration options.

type Pair

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

Pair - structure which holds a pair

type Service

Service is the CSI Mock service provider.

func New

func New() Service

New returns a new Service.

type SnapSession

type SnapSession struct {
	Source     string
	Name       string
	Generation int64
	Expired    bool
	Target     []types.SnapTarget
}

SnapSession is an intermediate structure to share session info

type TopologyConfig added in v2.3.0

type TopologyConfig struct {
	AllowedConnections []NodeConfig `yaml:"allowedConnections, omitempty" mapstructure:"allowedConnections"`
	DeniedConnections  []NodeConfig `yaml:"deniedConnections, omitempty" mapstructure:"deniedConnections"`
}

TopologyConfig defines set of allow and deny rules for multiple nodes

func ReadConfig added in v2.3.0

func ReadConfig(configPath string) (*TopologyConfig, error)

ReadConfig will read topology configmap on the default path into TopologyConfig struct

type VMHost added in v2.5.0

type VMHost struct {
	Ctx context.Context

	VM *object.VirtualMachine
	// contains filtered or unexported fields
}

VMHost - structure to hold the VM host

func NewVMHost added in v2.5.0

func NewVMHost(insecure bool, hostURLparam, user, pass string) (*VMHost, error)

NewVMHost connects to a ESXi or vCenter instance and returns a *VMHost This method is referenced from https://github.com/codedellemc/govmax/blob/master/api/v1/vmomi.go

func (*VMHost) AttachRDM added in v2.5.0

func (vmh *VMHost) AttachRDM(vm *object.VirtualMachine, deviceNAA string) (err error)

AttachRDM adds the device to the VM as an RDM This method is referenced from https://github.com/codedellemc/govmax/blob/master/api/v1/vmomi.go

func (*VMHost) DetachRDM added in v2.5.0

func (vmh *VMHost) DetachRDM(vm *object.VirtualMachine, deviceNAA string) error

DetachRDM removes the device from the VM This method is referenced from https://github.com/codedellemc/govmax/blob/master/api/v1/vmomi.go

func (*VMHost) GetSCSILuns added in v2.5.0

func (vmh *VMHost) GetSCSILuns() ([]*types.ScsiLun, error)

GetSCSILuns fetches all the SCSILuns discovered on the host This method is referenced from https://github.com/codedellemc/govmax/blob/master/api/v1/vmomi.go

func (*VMHost) RescanAllHba added in v2.5.0

func (vmh *VMHost) RescanAllHba(hostSystem *object.HostSystem) error

RescanAllHba rediscovers new devices added to the ESX This method is referenced from https://github.com/codedellemc/govmax/blob/master/api/v1/vmomi.go

Jump to

Keyboard shortcuts

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