driver

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2021 License: BSD-3-Clause Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PortDefault                  int           = 1247
	PerFileBlockCacheMaxDefault  int           = 3
	ConnectionMaxDefault         int           = 10
	OperationTimeoutDefault      time.Duration = 5 * time.Minute
	ConnectionIdleTimeoutDefault time.Duration = 5 * time.Minute
	CacheTimeoutDefault          time.Duration = 5 * time.Minute
	CacheCleanupTimeDefault      time.Duration = 5 * time.Minute
)

Variables

View Source
var (

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

Functions

func CheckIRODSVolume added in v0.2.0

func CheckIRODSVolume(id string) bool

CheckIRODSVolume returns presence of IRODSVolume with given id

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 PutIRODSVolume added in v0.2.0

func PutIRODSVolume(volume *IRODSVolume)

PutIRODSVolume puts IRODSVolume

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 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) 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) 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) Probe

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

Probe returns probe response

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
	MonitorURL   string
	PathMappings []IRODSFSPathMapping
}

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, monitorUrl string, pathMappings []IRODSFSPathMapping) *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"`
	MonitorURL   string               `yaml:"monitor_url"`

	PerFileBlockCacheMax  int           `yaml:"per_file_block_cache_max"`
	OperationTimeout      time.Duration `yaml:"operation_timeout"`
	ConnectionIdleTimeout time.Duration `yaml:"connection_idle_timeout"`
	ConnectionMax         int           `yaml:"connection_max"`
	CacheTimeout          time.Duration `yaml:"cache_timeout"`
	CacheCleanupTime      time.Duration `yaml:"cache_cleanup_time"`

	LogPath    string `yaml:"log_path,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
	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 IRODSVolume added in v0.2.0

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

IRODSVolume class

func GetIRODSVolume added in v0.2.0

func GetIRODSVolume(id string) *IRODSVolume

GetIRODSVolume returns IRODSVolume with given id

func NewIRODSVolume added in v0.2.0

func NewIRODSVolume(id string, name string, rootPath string, path string, connInfo *IRODSConnectionInfo, retainData bool) *IRODSVolume

NewIRODSVolume returns a new instance of IRODSVolume

func PopIRODSVolume added in v0.2.0

func PopIRODSVolume(id string) *IRODSVolume

PopIRODSVolume returns IRODSVolume with given id and delete

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
}

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.

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