utils

package
v1.10.0-RC1 Latest Latest
Warning

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

Go to latest
Published: May 7, 2020 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// NODEID is the node name on which this pod is currently scheduled
	NODEID = "nodeID"

	// VOLNAME is the name of the provisioned volume
	VOLNAME = "Volname"
)
View Source
const (

	// OpenebsVolumePolicy is the config policy name passed to CSI from the
	// storage class parameters
	OpenebsVolumePolicy = "openebs.io/volume-policy"
	// OpenebsVolumeID is the PV name passed to CSI
	OpenebsVolumeID = "openebs.io/volumeID"
	// OpenebsCSPCName is the name of cstor storagepool cluster
	OpenebsCSPCName = "openebs.io/cstor-pool-cluster"
	// CVCFinalizer is used for CVC protection so that cvc is not deleted until
	// the underlying cv is deleted
	CVCFinalizer = "cvc.openebs.io/finalizer"
	// TargetLunID indicates the LUN ID at the target
	TargetLunID = "0"
	// DefaultIscsiInterface can be used when there is no specific
	// IscsiInterface set
	DefaultIscsiInterface = "default"
)
View Source
const (

	// VolumeWaitTimeout indicates the timegap between two consecutive volume
	// status check attempts
	VolumeWaitTimeout = 2

	// VolumeWaitRetryCount indicates the number of retries made to check the
	// status of volume before erroring out
	VolumeWaitRetryCount = 6

	// MonitorMountRetryTimeout indicates the time gap between two consecutive
	//monitoring attempts
	MonitorMountRetryTimeout = 5
)
View Source
const (

	// GiB ...
	GiB = 1024 * 1024 * 1024
)

Variables

View Source
var (
	// OpenEBSNamespace is openebs system namespace
	OpenEBSNamespace string

	// NodeIDENV is the NodeID of the node on which the pod is present
	NodeIDENV string

	// TransitionVolList contains the list of volumes under transition
	// This list is protected by TransitionVolListLock
	TransitionVolList map[string]apis.CStorVolumeAttachmentStatus

	// TransitionVolListLock is required to protect the above Volumes list
	TransitionVolListLock sync.RWMutex

	// ReqMountList contains the list of volumes which are required
	// to be remounted. This list is secured by ReqMountListLock
	ReqMountList map[string]apis.CStorVolumeAttachmentStatus
)

Functions

func ByteCount

func ByteCount(b uint64) string

ByteCount converts bytes into corresponding unit

func BytesToGiB

func BytesToGiB(volumeSizeBytes int64) int64

BytesToGiB converts Bytes to GiB

func ChmodMountPath

func ChmodMountPath(mountPath string) error

ChmodMountPath removes all permission from the folder if volume is not mounted on it

func CreateCStorVolumeAttachmentCR

func CreateCStorVolumeAttachmentCR(csivol *apis.CStorVolumeAttachment, nodeID string) error

CreateCStorVolumeAttachmentCR creates a CSI VOlume CR

func CreateSnapshot

func CreateSnapshot(volumeName, snapName string) error

CreateSnapshot creates a snapshot of cstor volume

func DeleteCStorVolumeAttachmentCR

func DeleteCStorVolumeAttachmentCR(csivolName string) error

DeleteCStorVolumeAttachmentCR removes the CStorVolumeAttachmentCR for the specified path

func DeleteOldCStorVolumeAttachmentCRs

func DeleteOldCStorVolumeAttachmentCRs(volumeID string) error

DeleteOldCStorVolumeAttachmentCRs removes the CStorVolumeAttachmentCR for the specified path

func DeleteSnapshot

func DeleteSnapshot(volumeName, snapName string) error

DeleteSnapshot deletes a snapshot of cstor volume

func DeleteVolume

func DeleteVolume(volumeID string) (err error)

DeleteVolume deletes the corresponding CstorVolumeClaim(cvc) CR

func FetchAndUpdateISCSIDetails

func FetchAndUpdateISCSIDetails(volumeID string, vol *apis.CStorVolumeAttachment) error

FetchAndUpdateISCSIDetails fetches the iSCSI details from cstor volume resource and updates the corresponding csivolume resource

func FetchPVDetails

func FetchPVDetails(name string) (*corev1.PersistentVolume, error)

FetchPVDetails gets the PV related to this VolumeID

func GetCStorVolumeAttachment

func GetCStorVolumeAttachment(csivol string) (*apis.CStorVolumeAttachment, error)

GetCStorVolumeAttachment fetches the current Published csi Volume

func GetMounts

func GetMounts(volumeID string) ([]string, error)

GetMounts gets mountpoints for the specified volume

func GetVolList

func GetVolList(volume string) (*apis.CStorVolumeAttachmentList, error)

GetVolList fetches the current Published Volume list

func GetVolListForNode

func GetVolListForNode() (*apis.CStorVolumeAttachmentList, error)

GetVolListForNode fetches the current Published Volume list

func GetVolume

func GetVolume(volumeID string) (*apisv1.CStorVolumeConfig, error)

GetVolume the corresponding CstorVolumeClaim(cvc) CR

func GetVolumeIP

func GetVolumeIP(volumeID string) (string, error)

GetVolumeIP fetches the cstor target IP Address

func GetVolumeSourceDetails

func GetVolumeSourceDetails(snapshotID string) (string, string, error)

GetVolumeSourceDetails splits the volumeName and snapshot

func GiBToBytes

func GiBToBytes(volumeSizeGiB int64) int64

GiBToBytes converts GiB to Bytes

func IsCVCBound

func IsCVCBound(volumeID string) (bool, error)

IsCVCBound returns if the CV is bound to CVC or not

func IsSourceAvailable

func IsSourceAvailable(snapshotID string) (bool, error)

IsSourceAvailable returns true if the source volume is available

func MonitorMounts

func MonitorMounts()

MonitorMounts makes sure that all the volumes present in the inmemory list with the driver are mounted with the original mount options This function runs a never ending loop therefore should be run as a goroutine Mounted list is fetched from the OS and the state of all the volumes is reverified after every 5 seconds. If the mountpoint is not present in the list or if it has been remounted with a different mount option by the OS, the volume is added to the ReqMountList which is removed as soon as the remount operation on the volume is complete For each remount operation a new goroutine is created, so that if multiple volumes have lost their original state they can all be remounted in parallel

func PatchCVCNodeID

func PatchCVCNodeID(volumeID, nodeID string) error

PatchCVCNodeID patches the NodeID of CVC

func ProvisionVolume

func ProvisionVolume(
	size int64,
	volName,
	replicaCount,
	cspcName,
	snapshotID,
	nodeID,
	policyName string,
) error

ProvisionVolume creates a CstorVolumeClaim(cvc) CR, watcher for cvc is present in maya-apiserver

func RemountVolume

func RemountVolume(
	stagingPathExists bool, targetPathExists bool,
	vol *apis.CStorVolumeAttachment,
) (err error)

RemountVolume unmounts the volume if it is already mounted in an undesired state and then tries to mount again. If it is not mounted the volume, first the disk will be attached via iSCSI login and then it will be mounted

func ResizeVolume

func ResizeVolume(
	volumeID string,
	size int64,
) error

ResizeVolume updates the CstorVolumeClaim(cvc) CR, watcher for cvc is present in maya-apiserver

func RoundUpBytes

func RoundUpBytes(volumeSizeBytes int64) int64

RoundUpBytes rounds up the volume size in bytes upto multiplications of GiB in the unit of Bytes

func RoundUpGiB

func RoundUpGiB(volumeSizeBytes int64) int64

RoundUpGiB rounds up the volume size in bytes upto multiplications of GiB in the unit of GiB

func UpdateCStorVolumeAttachmentCR

func UpdateCStorVolumeAttachmentCR(csivol *apis.CStorVolumeAttachment) error

UpdateCStorVolumeAttachmentCR updates CStorVolumeAttachment CR related to current nodeID

func WaitForVolumeReadyAndReachable

func WaitForVolumeReadyAndReachable(vol *apis.CStorVolumeAttachment) error

WaitForVolumeReadyAndReachable waits until the volume is ready to accept IOs and is reachable, this function will not come out until both the conditions are met. This function stops the driver from overloading the OS with iSCSI login commands.

func WaitForVolumeToBeReachable

func WaitForVolumeToBeReachable(targetPortal string) error

WaitForVolumeToBeReachable keeps the mounts on hold until the volume is reachable

func WaitForVolumeToBeReady

func WaitForVolumeToBeReady(volumeID string) error

WaitForVolumeToBeReady retrieves the volume info from cstorVolume CR and waits until consistency factor is met for connected replicas

Types

type NodeMounter

type NodeMounter struct {
	mount.SafeFormatAndMount
}

func NewNodeMounter

func NewNodeMounter() *NodeMounter

func (*NodeMounter) ExistsPath

func (m *NodeMounter) ExistsPath(pathname string) (bool, error)

func (*NodeMounter) GetDeviceName

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

func (*NodeMounter) MakeDir

func (m *NodeMounter) MakeDir(pathname string) error

func (*NodeMounter) MakeFile

func (m *NodeMounter) MakeFile(pathname string) error

type NonBlockingGRPCServer

type NonBlockingGRPCServer interface {
	// Start services at the endpoint
	Start(endpoint string, ids csi.IdentityServer, cs csi.ControllerServer, ns csi.NodeServer)

	// Waits for the service to stop
	Wait()

	// Stops the service gracefully
	Stop()

	// Stops the service forcefully
	ForceStop()
}

NonBlockingGRPCServer defines Non blocking GRPC server interfaces

func NewNonBlockingGRPCServer

func NewNonBlockingGRPCServer() NonBlockingGRPCServer

NewNonBlockingGRPCServer returns a new instance of NonBlockingGRPCServer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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