driver

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2022 License: BSD-3-Clause Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PortDefault                     int           = 1247
	ReadAheadMaxDefault             int           = 1024 * 64 // 64KB
	ConnectionMaxDefault            int           = 10
	OperationTimeoutDefault         time.Duration = 5 * time.Minute
	ConnectionLifespanDefault       time.Duration = 1 * time.Hour
	ConnectionIdleTimeoutDefault    time.Duration = 5 * time.Minute
	MetadataCacheTimeoutDefault     time.Duration = 5 * time.Minute
	MetadataCacheCleanupTimeDefault time.Duration = 5 * time.Minute
	BufferSizeMaxDefault            int64         = 1024 * 1024 * 64 // 64MB
)

Variables

View Source
var (

	// DefaultVolumeSize specifies default volume size in Bytes
	DefaultVolumeSize int64 = 100 * 1024 * 1024 * 1024
)

Functions

func GetDriverVersion

func GetDriverVersion() string

GetDriverVersion returns driver version in string

func GetVersionJSON

func GetVersionJSON() (string, error)

GetVersionJSON returns VersionInfo object in JSON string

func IRODSMkdir added in v0.2.0

func IRODSMkdir(conn *IRODSConnectionInfo, path string) error

IRODSMkdir creates a new directory

func IRODSRmdir added in v0.2.0

func IRODSRmdir(conn *IRODSConnectionInfo, path string) error

IRODSRmdir deletes a directory

func IRODSTestConnection added in v0.3.0

func IRODSTestConnection(conn *IRODSConnectionInfo) error

IRODSTestConnection just test connection creation

func IsCorruptedMnt

func IsCorruptedMnt(err error) bool

IsCorruptedMnt return true if err is about corrupted mount point

func IsValidIRODSClientType added in v0.2.0

func IsValidIRODSClientType(client string) bool

IsValidIRODSClientType checks if given client string is valid

func ListProcMounts

func ListProcMounts(mountFilePath string) ([]mount.MountPoint, error)

ListProcMounts is shared with NsEnterMounter

func MakeDir

func MakeDir(path string) error

func MakeMountArgsSensitive

func MakeMountArgsSensitive(source, sourceMasked, target, fstype string, options []string, sensitiveOptions []string) (mountArgs []string, mountArgsLogStr string)

MakeMountArgsSensitive makes the arguments to the mount(8) command. sensitiveOptions is an extension of options except they will not be logged (because they may contain sensitive material)

func ParseEndpoint

func ParseEndpoint(endpoint string) (string, string, error)

ParseEndpoint parses endpoint string (TCP or UNIX)

func PathExists

func PathExists(path string) (bool, error)

PathExists returns true if the specified path exists. TODO: clean this up to use pkg/util/file/FileExists

func ReadIRODSSecrets added in v0.2.0

func ReadIRODSSecrets(secretPath string) (map[string]string, error)

ReadIRODSSecrets reads secrets from secret volume mount

func SearchMountPoints

func SearchMountPoints(hostSource, mountInfoPath string) ([]string, error)

SearchMountPoints finds all mount references to the source, returns a list of mountpoints. The source can be a mount point or a normal directory (bind mount). We didn't support device because there is no use case by now. Some filesystems may share a source name, e.g. tmpfs. And for bind mounting, it's possible to mount a non-root path of a filesystem, so we need to use root path and major:minor to represent mount source uniquely. This implementation is shared between Linux and NsEnterMounter

Types

type ClientType added in v0.2.2

type ClientType string

ClientType is a mount client type

const (
	// FuseType is for iRODS FUSE
	FuseType ClientType = "irodsfuse"
	// WebdavType is for WebDav client (Davfs2)
	WebdavType ClientType = "webdav"
	// NfsType is for NFS client
	NfsType ClientType = "nfs"
)

mount driver (iRODS Client) types

func ExtractIRODSClientType added in v0.2.0

func ExtractIRODSClientType(params map[string]string, secrets map[string]string, defaultClient ClientType) ClientType

ExtractIRODSClientType extracts iRODS Client value from param map

func GetValidiRODSClientType added in v0.2.2

func GetValidiRODSClientType(client string, defaultClient ClientType) ClientType

GetValidiRODSClientType checks if given client string is valid

type Config

type Config struct {
	Endpoint   string // CSI endpoint
	NodeID     string // node ID
	SecretPath string // Secret mount path
}

Config holds the parameters list which can be configured

type ControllerVolume added in v0.4.9

type ControllerVolume struct {
	ID             string
	Name           string
	RootPath       string
	Path           string
	ConnectionInfo *IRODSConnectionInfo
	RetainData     bool
}

ControllerVolume class

type Driver

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

Driver object contains configuration parameters, grpc server and mounter

func NewDriver

func NewDriver(conf *Config) *Driver

NewDriver returns new driver

func (*Driver) CheckControllerVolume added in v0.4.9

func (driver *Driver) CheckControllerVolume(id string) bool

CheckControllerVolume returns presence of ControllerVolume with given id

func (*Driver) CheckNodeVolume added in v0.4.9

func (driver *Driver) CheckNodeVolume(id string) bool

CheckNodeVolume returns presence of NodeVolume with given id

func (*Driver) ControllerExpandVolume added in v0.2.0

func (driver *Driver) ControllerExpandVolume(ctx context.Context, req *csi.ControllerExpandVolumeRequest) (*csi.ControllerExpandVolumeResponse, error)

ControllerExpandVolume expands a volume

func (*Driver) ControllerGetCapabilities added in v0.2.0

func (driver *Driver) ControllerGetCapabilities(ctx context.Context, req *csi.ControllerGetCapabilitiesRequest) (*csi.ControllerGetCapabilitiesResponse, error)

ControllerGetCapabilities returns capabilities

func (*Driver) ControllerPublishVolume added in v0.2.0

func (driver *Driver) ControllerPublishVolume(ctx context.Context, req *csi.ControllerPublishVolumeRequest) (*csi.ControllerPublishVolumeResponse, error)

ControllerPublishVolume handles persistent volume publish event in controller service

func (*Driver) ControllerUnpublishVolume added in v0.2.0

func (driver *Driver) ControllerUnpublishVolume(ctx context.Context, req *csi.ControllerUnpublishVolumeRequest) (*csi.ControllerUnpublishVolumeResponse, error)

ControllerUnpublishVolume handles persistent volume unpublish event in controller service

func (*Driver) CreateSnapshot added in v0.2.0

func (driver *Driver) CreateSnapshot(ctx context.Context, req *csi.CreateSnapshotRequest) (*csi.CreateSnapshotResponse, error)

CreateSnapshot creates a snapshot of a volume

func (*Driver) CreateVolume added in v0.2.0

func (driver *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest) (*csi.CreateVolumeResponse, error)

CreateVolume handles persistent volume creation event

func (*Driver) DeleteSnapshot added in v0.2.0

func (driver *Driver) DeleteSnapshot(ctx context.Context, req *csi.DeleteSnapshotRequest) (*csi.DeleteSnapshotResponse, error)

DeleteSnapshot deletes a snapshot of a volume

func (*Driver) DeleteVolume added in v0.2.0

func (driver *Driver) DeleteVolume(ctx context.Context, req *csi.DeleteVolumeRequest) (*csi.DeleteVolumeResponse, error)

DeleteVolume handles persistent volume deletion event

func (*Driver) GetCapacity added in v0.2.0

func (driver *Driver) GetCapacity(ctx context.Context, req *csi.GetCapacityRequest) (*csi.GetCapacityResponse, error)

GetCapacity returns volume capacity

func (*Driver) GetControllerVolume added in v0.4.9

func (driver *Driver) GetControllerVolume(id string) *ControllerVolume

GetControllerVolume returns ControllerVolume with given id

func (*Driver) GetNodeVolume added in v0.4.9

func (driver *Driver) GetNodeVolume(id string) *NodeVolume

GetNodeVolume returns NodeVolume with given id

func (*Driver) GetPluginCapabilities

func (driver *Driver) GetPluginCapabilities(ctx context.Context, req *csi.GetPluginCapabilitiesRequest) (*csi.GetPluginCapabilitiesResponse, error)

GetPluginCapabilities returns plugin capabilities

func (*Driver) GetPluginInfo

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

GetPluginInfo returns plugin info

func (*Driver) ListSnapshots added in v0.2.0

func (driver *Driver) ListSnapshots(ctx context.Context, req *csi.ListSnapshotsRequest) (*csi.ListSnapshotsResponse, error)

ListSnapshots returns a list of snapshots

func (*Driver) ListVolumes added in v0.2.0

func (driver *Driver) ListVolumes(ctx context.Context, req *csi.ListVolumesRequest) (*csi.ListVolumesResponse, error)

ListVolumes returns a list of volumes created

func (*Driver) NodeExpandVolume

func (driver *Driver) NodeExpandVolume(ctx context.Context, req *csi.NodeExpandVolumeRequest) (*csi.NodeExpandVolumeResponse, error)

NodeExpandVolume expands volume

func (*Driver) NodeGetCapabilities

func (driver *Driver) NodeGetCapabilities(ctx context.Context, req *csi.NodeGetCapabilitiesRequest) (*csi.NodeGetCapabilitiesResponse, error)

NodeGetCapabilities returns capabilities

func (*Driver) NodeGetInfo

func (driver *Driver) NodeGetInfo(ctx context.Context, req *csi.NodeGetInfoRequest) (*csi.NodeGetInfoResponse, error)

NodeGetInfo returns node info

func (*Driver) NodeGetVolumeStats

func (driver *Driver) NodeGetVolumeStats(ctx context.Context, req *csi.NodeGetVolumeStatsRequest) (*csi.NodeGetVolumeStatsResponse, error)

NodeGetVolumeStats returns volume stats

func (*Driver) NodePublishVolume

func (driver *Driver) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolumeRequest) (*csi.NodePublishVolumeResponse, error)

NodePublishVolume handles persistent volume publish event in node service

func (*Driver) NodeStageVolume

func (driver *Driver) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRequest) (*csi.NodeStageVolumeResponse, error)

NodeStageVolume handles persistent volume stage event in node service

func (*Driver) NodeUnpublishVolume

func (driver *Driver) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpublishVolumeRequest) (*csi.NodeUnpublishVolumeResponse, error)

NodeUnpublishVolume handles persistent volume unpublish event in node service

func (*Driver) NodeUnstageVolume

func (driver *Driver) NodeUnstageVolume(ctx context.Context, req *csi.NodeUnstageVolumeRequest) (*csi.NodeUnstageVolumeResponse, error)

NodeUnstageVolume handles persistent volume unstage event in node service

func (*Driver) PopControllerVolume added in v0.4.9

func (driver *Driver) PopControllerVolume(id string) *ControllerVolume

PopControllerVolume returns ControllerVolume with given id and delete

func (*Driver) PopNodeVolume added in v0.4.9

func (driver *Driver) PopNodeVolume(id string) *NodeVolume

PopNodeVolume returns NodeVolume with given id and delete

func (*Driver) Probe

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

Probe returns probe response

func (*Driver) PutControllerVolume added in v0.4.9

func (driver *Driver) PutControllerVolume(volume *ControllerVolume)

PutControllerVolume puts ControllerVolume

func (*Driver) PutNodeVolume added in v0.4.9

func (driver *Driver) PutNodeVolume(volume *NodeVolume)

PutNodeVolume puts NodeVolume

func (*Driver) Run

func (driver *Driver) Run() error

Run runs the driver service

func (*Driver) Stop added in v0.2.0

func (driver *Driver) Stop()

Stop stops the driver service

func (*Driver) ValidateVolumeCapabilities added in v0.2.0

func (driver *Driver) ValidateVolumeCapabilities(ctx context.Context, req *csi.ValidateVolumeCapabilitiesRequest) (*csi.ValidateVolumeCapabilitiesResponse, error)

ValidateVolumeCapabilities checks validity of volume capabilities

type IRODSConnectionInfo added in v0.3.0

type IRODSConnectionInfo struct {
	Hostname     string
	Port         int
	Zone         string
	User         string
	Password     string
	ClientUser   string // if this field has a value, user and password fields have proxy user info
	PoolHostname string
	PoolPort     int
	MonitorURL   string
	PathMappings []IRODSFSPathMapping
	UID          int
	GID          int
	SystemUser   string
	MountTimeout int
	Profile      bool
	ProfilePort  int
}

IRODSConnectionInfo class

func ExtractIRODSConnectionInfo added in v0.3.0

func ExtractIRODSConnectionInfo(params map[string]string, secrets map[string]string) (*IRODSConnectionInfo, error)

ExtractIRODSConnectionInfo extracts IRODSConnectionInfo value from param map

func NewIRODSConnectionInfo added in v0.3.0

func NewIRODSConnectionInfo(hostname string, port int, zone string, user string, password string, clientUser string, poolHost string, poolPort int, monitorUrl string, profile bool, profilePort int, pathMappings []IRODSFSPathMapping, uid int, gid int, systemUser string, mountTimeout int) *IRODSConnectionInfo

NewIRODSConnectionInfo returns a new instance of IRODSConnectionInfo

type IRODSFSConfig added in v0.3.0

type IRODSFSConfig struct {
	Host         string               `yaml:"host"`
	Port         int                  `yaml:"port"`
	ProxyUser    string               `yaml:"proxy_user"`
	ClientUser   string               `yaml:"client_user"`
	Zone         string               `yaml:"zone"`
	Password     string               `yaml:"password"`
	PathMappings []IRODSFSPathMapping `yaml:"path_mappings"`
	UID          int                  `yaml:"uid"`
	GID          int                  `yaml:"gid"`
	SystemUser   string               `yaml:"system_user"`

	PoolHost string `yaml:"pool_host,omitempty"`
	PoolPort int    `yaml:"pool_port,omitempty"`

	ReadAheadMax     int           `yaml:"read_ahead_max"`
	OperationTimeout time.Duration `yaml:"operation_timeout"`

	ConnectionLifespan       time.Duration `yaml:"connection_lifespan"`
	ConnectionIdleTimeout    time.Duration `yaml:"connection_idle_timeout"`
	ConnectionMax            int           `yaml:"connection_max"`
	MetadataCacheTimeout     time.Duration `yaml:"metadata_cache_timeout"`
	MetadataCacheCleanupTime time.Duration `yaml:"metadata_cache_cleanup_time"`
	BufferSizeMax            int64         `yaml:"buffer_size_max"`

	LogPath            string `yaml:"log_path,omitempty"`
	MonitorURL         string `yaml:"monitor_url,omitempty"`
	Profile            bool   `yaml:"profile,omitempty"`
	ProfileServicePort int    `yaml:"profile_service_port,omitempty"`
	AllowOther         bool   `yaml:"allow_other,omitempty"`
}

func NewDefaultIRODSFSConfig added in v0.3.0

func NewDefaultIRODSFSConfig() *IRODSFSConfig

NewDefaultIRODSFSConfig creates default IRODSFSConfig

type IRODSFSPathMapping added in v0.3.0

type IRODSFSPathMapping struct {
	IRODSPath      string `yaml:"irods_path" json:"irods_path"`
	MappingPath    string `yaml:"mapping_path" json:"mapping_path"`
	ResourceType   string `yaml:"resource_type" json:"resource_type"` // file or dir
	ReadOnly       bool   `yaml:"read_only" json:"read_only"`
	CreateDir      bool   `yaml:"create_dir" json:"create_dir"`
	IgnoreNotExist bool   `yaml:"ignore_not_exist" json:"ignore_not_exist"`
}

PathMapping ...

type IRODSNFSConnectionInfo added in v0.3.0

type IRODSNFSConnectionInfo struct {
	Hostname string
	Port     int
	Path     string
}

IRODSNFSConnectionInfo class

func ExtractIRODSNFSConnectionInfo added in v0.3.0

func ExtractIRODSNFSConnectionInfo(params map[string]string, secrets map[string]string) (*IRODSNFSConnectionInfo, error)

ExtractIRODSNFSConnectionInfo extracts IRODSNFSConnectionInfo value from param map

func NewIRODSNFSConnectionInfo added in v0.3.0

func NewIRODSNFSConnectionInfo(hostname string, port int, path string) *IRODSNFSConnectionInfo

NewIRODSNFSConnectionInfo returns a new instance of IRODSNFSConnectionInfo

type IRODSWebDAVConnectionInfo added in v0.3.0

type IRODSWebDAVConnectionInfo struct {
	URL      string
	User     string
	Password string
}

IRODSWebDAVConnectionInfo class

func ExtractIRODSWebDAVConnectionInfo added in v0.3.0

func ExtractIRODSWebDAVConnectionInfo(params map[string]string, secrets map[string]string) (*IRODSWebDAVConnectionInfo, error)

ExtractIRODSWebDAVConnectionInfo extracts IRODSWebDAVConnectionInfo value from param map

func NewIRODSWebDAVConnectionInfo added in v0.3.0

func NewIRODSWebDAVConnectionInfo(url string, user string, password string) *IRODSWebDAVConnectionInfo

NewIRODSWebDAVConnectionInfo returns a new instance of IRODSWebDAVConnectionInfo

type MountInfo

type MountInfo struct {
	// Unique ID for the mount (maybe reused after umount).
	ID int
	// The ID of the parent mount (or of self for the root of this mount namespace's mount tree).
	ParentID int
	// Major indicates one half of the device ID which identifies the device class
	// (parsed from `st_dev` for files on this filesystem).
	Major int
	// Minor indicates one half of the device ID which identifies a specific
	// instance of device (parsed from `st_dev` for files on this filesystem).
	Minor int
	// The pathname of the directory in the filesystem which forms the root of this mount.
	Root string
	// Mount source, filesystem-specific information. e.g. device, tmpfs name.
	Source string
	// Mount point, the pathname of the mount point.
	MountPoint string
	// Optional fieds, zero or more fields of the form "tag[:value]".
	OptionalFields []string
	// The filesystem type in the form "type[.subtype]".
	FsType string
	// Per-mount options.
	MountOptions []string
	// Per-superblock options.
	SuperOptions []string
}

MountInfo represents a single line in /proc/<pid>/mountinfo.

func ParseMountInfo

func ParseMountInfo(filename string) ([]MountInfo, error)

ParseMountInfo parses /proc/xxx/mountinfo.

type Mounter

type Mounter interface {
	mount.Interface
	GetDeviceName(mountPath string) (string, int, error)
	MountSensitive2(source string, sourceMasked string, target string, fstype string, options []string, sensitiveOptions []string, stdinValues []string) error
	UnmountForcefully(target string) error
}

type NodeMounter

type NodeMounter struct {
	mount.Interface
}

func (*NodeMounter) GetDeviceName

func (mounter *NodeMounter) GetDeviceName(mountPath string) (string, int, error)

func (*NodeMounter) GetMountRefs

func (mounter *NodeMounter) GetMountRefs(pathname string) ([]string, error)

GetMountRefs finds all mount references to pathname, returns a list of paths. Path could be a mountpoint or a normal directory (for bind mount).

func (*NodeMounter) IsLikelyNotMountPoint

func (mounter *NodeMounter) IsLikelyNotMountPoint(file string) (bool, error)

IsLikelyNotMountPoint determines if a directory is not a mountpoint. It is fast but not necessarily ALWAYS correct. If the path is in fact a bind mount from one part of a mount to another it will not be detected. It also can not distinguish between mountpoints and symbolic links. mkdir /tmp/a /tmp/b; mount --bind /tmp/a /tmp/b; IsLikelyNotMountPoint("/tmp/b") will return true. When in fact /tmp/b is a mount point. If this situation is of interest to you, don't use this function...

func (*NodeMounter) List

func (mounter *NodeMounter) List() ([]mount.MountPoint, error)

List returns a list of all mounted filesystems.

func (*NodeMounter) Mount

func (mounter *NodeMounter) Mount(source string, target string, fstype string, options []string) error

Mount mounts source to target as fstype with given options. 'source' and 'fstype' must be an empty string in case it's not required, e.g. for remount, or for auto filesystem type, where kernel handles fstype for you. The mount 'options' is a list of options, currently come from mount(8), e.g. "ro", "remount", "bind", etc. If no more option is required, call Mount with an empty string list or nil.

func (*NodeMounter) MountSensitive

func (mounter *NodeMounter) MountSensitive(source string, target string, fstype string, options []string, sensitiveOptions []string) error

MountSensitive is the same as Mount() but this method allows sensitiveOptions to be passed in a separate parameter from the normal mount options and ensures the sensitiveOptions are never logged. This method should be used by callers that pass sensitive material (like passwords) as mount options.

func (*NodeMounter) MountSensitive2

func (mounter *NodeMounter) MountSensitive2(source string, sourceMasked string, target string, fstype string, options []string, sensitiveOptions []string, stdinValues []string) error

func (*NodeMounter) Unmount

func (mounter *NodeMounter) Unmount(target string) error

Unmount unmounts the target.

func (*NodeMounter) UnmountForcefully added in v0.4.10

func (mounter *NodeMounter) UnmountForcefully(target string) error

Unmount unmounts the target forcefully after initial try of unmount.

type NodeVolume added in v0.4.9

type NodeVolume struct {
	ID                        string
	StagingMountPath          string
	MountPath                 string
	DynamicVolumeProvisioning bool
	StageVolume               bool
}

NodeVolume class

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"`
}

VersionInfo object contains version related info

func GetVersion

func GetVersion() VersionInfo

GetVersion returns VersionInfo object

Jump to

Keyboard shortcuts

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