driver

package
v1.11.1 Latest Latest
Warning

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

Go to latest
Published: May 14, 2023 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Overview

*

  • Copyright 2019 IBM Corp. *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

Index

Constants

View Source
const (
	DefualtConfigFile     string = "config.yaml"
	EnvNameDriverConfFile string = "DRIVER_CONFIG_YML"
)
View Source
const (
	FCPath          = "/sys/class/fc_host"
	FCPortPath      = "/sys/class/fc_host/host*/port_name"
	MaxNodeIdLength = 256
)
View Source
const (
	// In the Dockerfile of the node, specific commands (e.g: multipath, mount...) from the host mounted inside the container in /host directory.
	// Command lines inside the container will show /host prefix.
	PrefixChrootOfHostRoot = "/host"

	TimeOutGeneralCmd    = 10 * 1000
	TimeOutMultipathdCmd = TimeOutGeneralCmd
	TimeOutNvmeCmd       = TimeOutGeneralCmd

	BlockDevCmd = "blockdev"
)

Variables

View Source
var (
	StageInfoFilename = ".stageInfo.json"

	NvmeFullPath  = "/host/etc/nvme/hostnqn"
	IscsiFullPath = "/host/etc/iscsi/initiatorname.iscsi"
)
View Source
var ErrorNoPortsCouldFitInNodeId = "could not fit any ports in node id: %v, length limit: %d"
View Source
var ErrorUnsupportedConnectivityType = "Unsupported connectivity type : {%v}"
View Source
var ErrorWhileTryingToReadPort = "Error while trying to get %s port from string: %v."

Functions

func GetVersionJSON

func GetVersionJSON(configFilePath string) (string, error)

Types

type ConfigFile

type ConfigFile struct {
	Identity          Identity
	Controller        Controller
	Parameters        Parameters
	Connectivity_type Connectivity_type
}

func ReadConfigFile

func ReadConfigFile(configFilePath string) (ConfigFile, error)

type ConfigYmlEmptyAttribute

type ConfigYmlEmptyAttribute struct {
	Attr string
}

func (*ConfigYmlEmptyAttribute) Error

func (e *ConfigYmlEmptyAttribute) Error() string

type Connectivity_type added in v1.10.0

type Connectivity_type struct {
	Nvme_over_fc string
	Fc           string
	Iscsi        string
}

type Controller added in v1.10.0

type Controller struct {
	Publish_context_lun_parameter          string
	Publish_context_connectivity_parameter string
	Publish_context_separator              string
	Publish_context_array_iqn              string
	Publish_context_fc_initiators          string
}

type Driver

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

func NewDriver

func NewDriver(endpoint string, configFilePath string, hostname string) (*Driver, error)

func (*Driver) GetPluginInfo

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

func (*Driver) Probe

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

func (*Driver) Run

func (d *Driver) Run() error

func (*Driver) Stop

func (d *Driver) Stop()

type Identity added in v1.10.0

type Identity struct {
	Name    string
	Version string
}

type NodeMounter added in v1.1.0

type NodeMounter interface {
	mount.Interface
	FormatAndMount(source string, target string, fstype string, options []string) error
	GetDiskFormat(disk string) (string, error)
}

type NodeService

type NodeService struct {
	Mounter    NodeMounter
	ConfigYaml ConfigFile
	Hostname   string
	NodeUtils  NodeUtilsInterface

	VolumeIdLocksMap            SyncLockInterface
	OsDeviceConnectivityMapping map[string]device_connectivity.OsDeviceConnectivityInterface
	OsDeviceConnectivityHelper  device_connectivity.OsDeviceConnectivityHelperScsiGenericInterface
	// contains filtered or unexported fields
}

nodeService represents the node service of CSI driver

func NewNodeService

func NewNodeService(configYaml ConfigFile, hostname string, nodeUtils NodeUtilsInterface,
	OsDeviceConnectivityMapping map[string]device_connectivity.OsDeviceConnectivityInterface,
	osDeviceConnectivityHelper device_connectivity.OsDeviceConnectivityHelperScsiGenericInterface,
	executer executer.ExecuterInterface, mounter NodeMounter, syncLock SyncLockInterface) NodeService

newNodeService creates a new node service it panics if failed to create the service

func (*NodeService) NodeExpandVolume

func (*NodeService) NodeGetCapabilities

func (*NodeService) NodeGetInfo

func (*NodeService) NodeGetVolumeStats

func (*NodeService) NodePublishVolume

func (*NodeService) NodeStageVolume

func (*NodeService) NodeUnpublishVolume

func (*NodeService) NodeUnstageVolume

type NodeUtils

type NodeUtils struct {
	Executer executer.ExecuterInterface

	ConfigYaml ConfigFile
	// contains filtered or unexported fields
}

func NewNodeUtils

func NewNodeUtils(executer executer.ExecuterInterface, mounter mount.Interface, configYaml ConfigFile,
	osDeviceConnectivityHelper device_connectivity.OsDeviceConnectivityHelperScsiGenericInterface) *NodeUtils

func (NodeUtils) ClearStageInfoFile

func (n NodeUtils) ClearStageInfoFile(filePath string) error

func (NodeUtils) DevicesAreNvme added in v1.8.0

func (n NodeUtils) DevicesAreNvme(sysDevices []string) (bool, error)

func (NodeUtils) ExpandFilesystem added in v1.4.0

func (n NodeUtils) ExpandFilesystem(devicePath string, volumePath string, fsType string) error

func (NodeUtils) ExpandMpathDevice added in v1.4.0

func (n NodeUtils) ExpandMpathDevice(mpathDevice string) error

func (NodeUtils) FormatDevice added in v1.4.0

func (n NodeUtils) FormatDevice(devicePath string, fsType string)

func (NodeUtils) GenerateNodeID added in v1.4.0

func (n NodeUtils) GenerateNodeID(hostName string, nvmeNQN string, fcWWNs []string, iscsiIQN string) (string, error)

func (NodeUtils) GetArrayInitiators added in v1.1.0

func (n NodeUtils) GetArrayInitiators(ipsByArrayInitiator map[string][]string) []string

func (NodeUtils) GetBlockVolumeStats added in v1.9.0

func (d NodeUtils) GetBlockVolumeStats(volumeId string) (VolumeStatistics, error)

func (NodeUtils) GetFileSystemVolumeStats added in v1.9.0

func (d NodeUtils) GetFileSystemVolumeStats(path string) (VolumeStatistics, error)

func (NodeUtils) GetInfoFromPublishContext

func (n NodeUtils) GetInfoFromPublishContext(publishContext map[string]string) (string, int, map[string][]string, error)

func (NodeUtils) GetPodPath added in v1.1.0

func (n NodeUtils) GetPodPath(origPath string) string

To some files/dirs pod cannot access using its real path. It has to use a different path which is <prefix>/<path>. E.g. in order to access /etc/test.txt pod has to use /host/etc/test.txt

func (NodeUtils) GetSysDevicesFromMpath

func (n NodeUtils) GetSysDevicesFromMpath(baseDevice string) ([]string, error)

func (NodeUtils) GetTopologyLabels added in v1.6.0

func (n NodeUtils) GetTopologyLabels(ctx context.Context, nodeName string) (map[string]string, error)

func (NodeUtils) GetVolumeUuid added in v1.10.0

func (d NodeUtils) GetVolumeUuid(volumeId string) string

func (NodeUtils) IsBlock added in v1.9.0

func (n NodeUtils) IsBlock(devicePath string) (bool, error)

func (NodeUtils) IsDirectory added in v1.1.0

func (n NodeUtils) IsDirectory(path string) bool

func (NodeUtils) IsFCExists added in v1.7.0

func (n NodeUtils) IsFCExists() bool

func (NodeUtils) IsNotMountPoint added in v1.1.0

func (n NodeUtils) IsNotMountPoint(file string) (bool, error)

func (NodeUtils) IsPathExists added in v1.1.0

func (n NodeUtils) IsPathExists(path string) bool

func (NodeUtils) MakeDir added in v1.4.0

func (n NodeUtils) MakeDir(dirPath string) error

func (NodeUtils) MakeFile added in v1.4.0

func (n NodeUtils) MakeFile(filePath string) error

func (NodeUtils) ParseFCPorts added in v0.9.0

func (n NodeUtils) ParseFCPorts() ([]string, error)

func (NodeUtils) ParseIscsiInitiators

func (n NodeUtils) ParseIscsiInitiators() (string, error)

func (NodeUtils) ReadNvmeNqn added in v1.8.0

func (n NodeUtils) ReadNvmeNqn() (string, error)

func (NodeUtils) RemoveFileOrDirectory added in v1.1.0

func (n NodeUtils) RemoveFileOrDirectory(path string) error

Deletes file or directory with all sub-directories and files

func (NodeUtils) RescanPhysicalDevices added in v1.4.0

func (n NodeUtils) RescanPhysicalDevices(sysDevices []string) error

func (NodeUtils) StageInfoFileIsExist

func (n NodeUtils) StageInfoFileIsExist(filePath string) bool

type NodeUtilsInterface

type NodeUtilsInterface interface {
	GetVolumeUuid(volumeId string) string
	ReadNvmeNqn() (string, error)
	DevicesAreNvme(sysDevices []string) (bool, error)
	ParseFCPorts() ([]string, error)
	ParseIscsiInitiators() (string, error)
	GetInfoFromPublishContext(publishContext map[string]string) (string, int, map[string][]string, error)
	GetArrayInitiators(ipsByArrayInitiator map[string][]string) []string
	GetSysDevicesFromMpath(baseDevice string) ([]string, error)

	// TODO refactor and move all staging methods to dedicate interface.
	ClearStageInfoFile(filePath string) error
	StageInfoFileIsExist(filePath string) bool
	IsPathExists(filePath string) bool
	IsFCExists() bool
	IsDirectory(filePath string) bool
	RemoveFileOrDirectory(filePath string) error
	MakeDir(dirPath string) error
	MakeFile(filePath string) error
	ExpandFilesystem(devicePath string, volumePath string, fsType string) error
	ExpandMpathDevice(mpathDevice string) error
	RescanPhysicalDevices(sysDevices []string) error
	FormatDevice(devicePath string, fsType string)
	IsNotMountPoint(file string) (bool, error)
	GetPodPath(filepath string) string
	GenerateNodeID(hostName string, nvmeNQN string, fcWWNs []string, iscsiIQN string) (string, error)
	GetTopologyLabels(ctx context.Context, nodeName string) (map[string]string, error)
	IsBlock(devicePath string) (bool, error)
	GetFileSystemVolumeStats(path string) (VolumeStatistics, error)
	GetBlockVolumeStats(volumeId string) (VolumeStatistics, error)
}

type Node_id_info added in v1.10.0

type Node_id_info struct {
	Delimiter     string
	Fcs_delimiter string
}

type Object_id_info added in v1.10.0

type Object_id_info struct {
	Delimiter     string
	Ids_delimiter string
}

type Parameters added in v1.10.0

type Parameters struct {
	Object_id_info Object_id_info
	Node_id_info   Node_id_info
}

type RequestValidationError

type RequestValidationError struct {
	Msg string
}

func (*RequestValidationError) Error

func (e *RequestValidationError) Error() string

type SyncLock

type SyncLock struct {
	SyncMap *sync.Map
}

func (SyncLock) AddVolumeLock

func (s SyncLock) AddVolumeLock(id string, msg string) error

func (SyncLock) GetSyncMap

func (s SyncLock) GetSyncMap() *sync.Map

func (SyncLock) RemoveVolumeLock

func (s SyncLock) RemoveVolumeLock(id string, msg string)

type SyncLockInterface

type SyncLockInterface interface {
	AddVolumeLock(id string, msg string) error
	RemoveVolumeLock(id string, msg string)
	GetSyncMap() *sync.Map
}

func NewSyncLock

func NewSyncLock() SyncLockInterface

type VersionInfo

type VersionInfo struct {
	DriverVersion string `json:"driverVersion"`
	GitCommit     string `json:"gitCommit"`
	BuildDate     string `json:"buildDate"`
	GoVersion     string `json:"goVersion"`
	Compiler      string `json:"compiler"`
	Platform      string `json:"platform"`
}

func GetVersion

func GetVersion(configFilePath string) (VersionInfo, error)

type VolumeAlreadyProcessingError

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

func (*VolumeAlreadyProcessingError) Error

type VolumeStatistics added in v1.9.0

type VolumeStatistics struct {
	AvailableBytes, TotalBytes, UsedBytes    int64
	AvailableInodes, TotalInodes, UsedInodes int64
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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