lvm

package
v0.6.0-RC2 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2021 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DevPath       = "/dev/"
	DevMapperPath = "/dev/mapper/"
	// MinExtentRoundOffSize represents minimum size (256Mi) to roundoff the volume
	// group size in case of thin pool provisioning
	MinExtentRoundOffSize = 268435456

	// BlockCleanerCommand is the command used to clean filesystem on the device
	BlockCleanerCommand = "wipefs"
)

lvm related constants

View Source
const (
	VGCreate = "vgcreate"
	VGList   = "vgs"

	LVCreate = "lvcreate"
	LVRemove = "lvremove"
	LVExtend = "lvextend"
	LVS      = "lvs"

	PVScan = "pvscan"

	YES = "yes"
)

lvm command related constants

View Source
const (
	// LvmNamespaceKey is the environment variable to get openebs namespace
	//
	// This environment variable is set via kubernetes downward API
	LvmNamespaceKey string = "LVM_NAMESPACE"
	// GoogleAnalyticsKey This environment variable is set via env
	GoogleAnalyticsKey string = "OPENEBS_IO_ENABLE_ANALYTICS"
	// LVMFinalizer for the LVMVolume CR
	LVMFinalizer string = "lvm.openebs.io/finalizer"
	// VolGroupKey is key for LVM group name
	VolGroupKey string = "openebs.io/volgroup"
	// LVMVolKey for the LVMSnapshot CR to store Persistence Volume name
	LVMVolKey string = "openebs.io/persistent-volume"
	// LVMNodeKey will be used to insert Label in LVMVolume CR
	LVMNodeKey string = "kubernetes.io/nodename"
	// LVMTopologyKey is supported topology key for the lvm driver
	LVMTopologyKey string = "openebs.io/nodename"
	// LVMStatusPending shows object has not handled yet
	LVMStatusPending string = "Pending"
	// LVMStatusFailed shows object operation has failed
	LVMStatusFailed string = "Failed"
	// LVMStatusReady shows object has been processed
	LVMStatusReady string = "Ready"
	// OpenEBSCasTypeKey for the cas-type label
	OpenEBSCasTypeKey string = "openebs.io/cas-type"
	// LVMCasTypeName for the name of the cas-type
	LVMCasTypeName string = "localpv-lvm"
)

Variables

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

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

	// GoogleAnalyticsEnabled should send google analytics or not
	GoogleAnalyticsEnabled string
)

Functions

func CheckVolumeExists added in v0.2.0

func CheckVolumeExists(vol *apis.LVMVolume) (bool, error)

CheckVolumeExists validates if lvm volume exists

func CreateSnapshot added in v0.2.0

func CreateSnapshot(snap *apis.LVMSnapshot) error

CreateSnapshot creates the lvm volume snapshot

func CreateVolume

func CreateVolume(vol *apis.LVMVolume) error

CreateVolume creates the lvm volume

func DeleteSnapshot added in v0.2.0

func DeleteSnapshot(snapName string) error

DeleteSnapshot deletes the LVMSnapshot CR

func DeleteVolume

func DeleteVolume(volumeID string) (err error)

DeleteVolume deletes the corresponding LVM Volume CR

func DestroySnapshot added in v0.2.0

func DestroySnapshot(snap *apis.LVMSnapshot) error

DestroySnapshot deletes the lvm volume snapshot

func DestroyVolume

func DestroyVolume(vol *apis.LVMVolume) error

DestroyVolume deletes the lvm volume

func FormatAndMountVol

func FormatAndMountVol(devicePath string, mountInfo *MountInfo) error

FormatAndMountVol formats and mounts the created volume to the desired mount path

func GetLVMSnapshot added in v0.2.0

func GetLVMSnapshot(snapID string) (*apis.LVMSnapshot, error)

GetLVMSnapshot fetches the given LVM snapshot

func GetLVMSnapshotStatus added in v0.2.0

func GetLVMSnapshotStatus(snapID string) (string, error)

GetLVMSnapshotStatus returns the status of LVMSnapshot

func GetLVMVolume

func GetLVMVolume(volumeID string) (*apis.LVMVolume, error)

GetLVMVolume fetches the given LVMVolume

func GetLVMVolumeState

func GetLVMVolumeState(volID string) (string, string, error)

GetLVMVolumeState returns LVMVolume OwnerNode and State for the given volume. CreateVolume request may call it again and again until volume is "Ready".

func GetSnapshotForVolume added in v0.2.0

func GetSnapshotForVolume(volumeID string) (*apis.LVMSnapshotList, error)

GetSnapshotForVolume fetches all the snapshots for the given volume

func GetVolumeDevPath

func GetVolumeDevPath(vol *apis.LVMVolume) (string, error)

GetVolumeDevPath returns devpath for the given volume

func ListLVMVolumeGroup added in v0.3.0

func ListLVMVolumeGroup() ([]apis.VolumeGroup, error)

ListLVMVolumeGroup invokes `vgs` to list all the available volume groups in the node.

func MountBlock added in v0.2.0

func MountBlock(vol *apis.LVMVolume, mountinfo *MountInfo, podLVInfo *PodLVInfo) error

MountBlock mounts the block disk to the specified path

func MountFilesystem

func MountFilesystem(vol *apis.LVMVolume, mount *MountInfo, podinfo *PodLVInfo) error

MountFilesystem mounts the disk to the specified path

func MountVolume

func MountVolume(vol *apis.LVMVolume, mount *MountInfo, podLVInfo *PodLVInfo) error

MountVolume mounts the disk to the specified path

func ProvisionSnapshot added in v0.2.0

func ProvisionSnapshot(snap *apis.LVMSnapshot) error

ProvisionSnapshot creates a LVMSnapshot CR

func ProvisionVolume

func ProvisionVolume(vol *apis.LVMVolume) (*apis.LVMVolume, error)

ProvisionVolume creates a LVMVolume CR, watcher for volume is present in CSI agent

func ReloadLVMMetadataCache added in v0.4.0

func ReloadLVMMetadataCache() error

ReloadLVMMetadataCache refreshes lvmetad daemon cache used for serving vgs or other lvm utility.

func RemoveSnapFinalizer added in v0.2.0

func RemoveSnapFinalizer(snap *apis.LVMSnapshot) error

RemoveSnapFinalizer adds finalizer to LVMSnapshot CR

func RemoveVolFinalizer

func RemoveVolFinalizer(vol *apis.LVMVolume) error

RemoveVolFinalizer adds finalizer to LVMVolume CR

func ResizeLVMVolume

func ResizeLVMVolume(vol *apis.LVMVolume, resizefs bool) error

ResizeLVMVolume resizes the underlying LVM volume and FS if resizefs is set to true Note:

  1. Triggering `lvextend <dev_path> -L <size> -r` multiple times with same size will not return any errors
  2. Triggering `lvextend <dev_path> -L <size>` more than one time will cause errors

func ResizeVolume

func ResizeVolume(vol *apis.LVMVolume, newSize int64) error

ResizeVolume resizes the lvm volume

func SetIORateLimits added in v0.3.0

func SetIORateLimits(config *config.Config)

SetIORateLimits sets io limit rates for the volume group (prefixes) provided in config

func UmountVolume

func UmountVolume(vol *apis.LVMVolume, targetPath string,
) error

UmountVolume unmounts the volume and the corresponding mount path is removed

func UpdateSnapInfo added in v0.2.0

func UpdateSnapInfo(snap *apis.LVMSnapshot) error

UpdateSnapInfo updates LVMSnapshot CR with node id and finalizer

func UpdateVolGroup added in v0.5.0

func UpdateVolGroup(vol *apis.LVMVolume, vgName string) (*apis.LVMVolume, error)

UpdateVolGroup updates LVMVolume CR with volGroup name.

func UpdateVolInfo

func UpdateVolInfo(vol *apis.LVMVolume, state string) error

UpdateVolInfo updates LVMVolume CR with node id and finalizer

func WaitForLVMVolumeDestroy added in v0.3.0

func WaitForLVMVolumeDestroy(ctx context.Context, volumeID string) error

WaitForLVMVolumeDestroy waits till the lvm volume gets deleted.

func WaitForLVMVolumeProcessed added in v0.3.0

func WaitForLVMVolumeProcessed(ctx context.Context, volumeID string) (*apis.LVMVolume, error)

WaitForLVMVolumeProcessed waits till the lvm volume becomes ready or failed (i.e reaches to terminal state).

Types

type ExecError added in v0.3.0

type ExecError struct {
	Output []byte
	Err    error
}

ExecError holds the process output along with underlying error returned by exec.CombinedOutput function.

func (*ExecError) Error added in v0.3.0

func (e *ExecError) Error() string

Error implements the error interface.

type MountInfo

type MountInfo struct {
	// FSType of a volume will specify the
	// format type - ext4(default), xfs of PV
	FSType string `json:"fsType"`

	// AccessMode of a volume will hold the
	// access mode of the volume
	AccessModes []string `json:"accessModes"`

	// MountPath of the volume will hold the
	// path on which the volume is mounted
	// on that node
	MountPath string `json:"mountPath"`

	// MountOptions specifies the options with
	// which mount needs to be attempted
	MountOptions []string `json:"mountOptions"`
}

MountInfo contains the volume related info for all types of volumes in LVMVolume

type PodLVInfo added in v0.3.0

type PodLVInfo struct {
	// UID is the Uid of the pod
	UID string

	// LVGroup is the LVM vg name in which lv needs to be provisioned
	LVGroup string
}

PodLVInfo contains the pod, LVGroup related info

Jump to

Keyboard shortcuts

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