lvm

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VGName              = "vg_name"
	VGUUID              = "vg_uuid"
	VGPVvount           = "pv_count"
	VGLvCount           = "lv_count"
	VGMaxLv             = "max_lv"
	VGMaxPv             = "max_pv"
	VGSnapCount         = "snap_count"
	VGMissingPvCount    = "vg_missing_pv_count"
	VGMetadataCount     = "vg_mda_count"
	VGMetadataUsedCount = "vg_mda_used_count"
	VGSize              = "vg_size"
	VGFreeSize          = "vg_free"
	VGMetadataSize      = "vg_mda_size"
	VGMetadataFreeSize  = "vg_mda_free"
	VGPermissions       = "vg_permissions"
	VGAllocationPolicy  = "vg_allocation_policy"

	LVName            = "lv_name"
	LVFullName        = "lv_full_name"
	LVUUID            = "lv_uuid"
	LVPath            = "lv_path"
	LVDmPath          = "lv_dm_path"
	LVActive          = "lv_active"
	LVSize            = "lv_size"
	LVMetadataSize    = "lv_metadata_size"
	LVSegtype         = "segtype"
	LVHost            = "lv_host"
	LVPool            = "pool_lv"
	LVPermissions     = "lv_permissions"
	LVWhenFull        = "lv_when_full"
	LVHealthStatus    = "lv_health_status"
	RaidSyncAction    = "raid_sync_action"
	LVDataPercent     = "data_percent"
	LVMetadataPercent = "metadata_percent"
	LVSnapPercent     = "snap_percent"

	PVName             = "pv_name"
	PVUUID             = "pv_uuid"
	PVInUse            = "pv_in_use"
	PVAllocatable      = "pv_allocatable"
	PVMissing          = "pv_missing"
	PVSize             = "pv_size"
	PVFreeSize         = "pv_free"
	PVUsedSize         = "pv_used"
	PVMetadataSize     = "pv_mda_size"
	PVMetadataFreeSize = "pv_mda_free"
	PVDeviceSize       = "dev_size"
)

lvm vg, lv & pv fields related 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"
	LVList   = "lvs"

	PVList = "pvs"
	PVScan = "pvscan"

	YES        = "yes"
	LVThinPool = "thin-pool"
)

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
)
View Source
var (
	Enums = map[string][]string{
		"lv_permissions":       {"unknown", "writeable", "read-only", "read-only-override"},
		"lv_when_full":         {"error", "queue"},
		"raid_sync_action":     {"idle", "frozen", "resync", "recover", "check", "repair"},
		"lv_health_status":     {"", "partial", "refresh needed", "mismatches exist"},
		"vg_allocation_policy": {"normal", "contiguous", "cling", "anywhere", "inherited"},
		"vg_permissions":       {"writeable", "read-only"},
	}
)

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 GetRBpsPerGB added in v1.3.0

func GetRBpsPerGB(vgName string) uint64

GetRBpsPerGB returns read bps rates for the volume group name (or prefix)

func GetRIopsPerGB added in v1.3.0

func GetRIopsPerGB(vgName string) uint64

GetRIopsPerGB returns read iops rates for the volume group name (or prefix)

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 GetWBpsPerGB added in v1.3.0

func GetWBpsPerGB(vgName string) uint64

GetWBpsPerGB returns write bps rates for the volume group name (or prefix)

func GetWIopsPerGB added in v1.3.0

func GetWIopsPerGB(vgName string) uint64

GetWIopsPerGB returns write iops rates for the volume group name (or prefix)

func ListLVMVolumeGroup added in v0.3.0

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

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

In case reloadCache is false, we skip refreshing lvm metadata cache.

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 RunCommandSplit added in v1.3.0

func RunCommandSplit(command string, args ...string) ([]byte, []byte, error)

RunCommandSplit is a wrapper function to run a command and receive its STDERR and STDOUT streams in separate []byte vars.

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 LogicalVolume added in v0.7.0

type LogicalVolume struct {

	// Name of the lvm logical volume(name: pvc-213ca1e6-e271-4ec8-875c-c7def3a4908d)
	Name string

	// Full name of the lvm logical volume (fullName: linuxlvmvg/pvc-213ca1e6-e271-4ec8-875c-c7def3a4908d)
	FullName string

	// UUID denotes a unique identity of a lvm logical volume.
	UUID string

	// Size specifies the total size of logical volume in Bytes
	Size int64

	// Path specifies LVM logical volume path
	Path string

	// DMPath specifies device mapper path
	DMPath string

	// LVM logical volume device
	Device string

	// Name of the VG in which LVM logical volume is created
	VGName string

	// SegType specifies the type of Logical volume segment
	SegType string

	// Permission indicates the logical volume permission.
	// Permission has the following mapping between
	// int and string for its value:
	// [-1: "", 0: "unknown", 1: "writeable", 2: "read-only", 3: "read-only-override"]
	Permission int

	// BehaviourWhenFull indicates the behaviour of thin pools when it is full.
	// BehaviourWhenFull has the following mapping between int and string for its value:
	// [-1: "", 0: "error", 1: "queue"]
	BehaviourWhenFull int

	// HealthStatus indicates the health status of logical volumes.
	// HealthStatus has the following mapping between int and string for its value:
	// [0: "", 1: "partial", 2: "refresh needed", 3: "mismatches exist"]
	HealthStatus int

	// RaidSyncAction indicates the current synchronization action being performed for RAID
	// action.
	// RaidSyncAction has the following mapping between int and string for its value:
	// [-1: "", 0: "idle", 1: "frozen", 2: "resync", 3: "recover", 4: "check", 5: "repair"]
	RaidSyncAction int

	// ActiveStatus indicates the active state of logical volume
	ActiveStatus string

	// Host specifies the creation host of the logical volume, if known
	Host string

	// For thin volumes, the thin pool Logical volume for that volume
	PoolName string

	// UsedSizePercent specifies the percentage full for snapshot, cache
	// and thin pools and volumes if logical volume is active.
	UsedSizePercent float64

	// MetadataSize specifies the size of the logical volume that holds
	// the metadata for thin and cache pools.
	MetadataSize int64

	// MetadataUsedPercent specifies the percentage of metadata full if logical volume
	// is active for cache and thin pools.
	MetadataUsedPercent float64

	// SnapshotUsedPercent specifies the percentage full for snapshots  if
	// logical volume is active.
	SnapshotUsedPercent float64
}

LogicalVolume specifies attributes of a given lv that exists on the node.

func ListLVMLogicalVolume added in v0.7.0

func ListLVMLogicalVolume() ([]LogicalVolume, error)

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 PhysicalVolume added in v0.8.0

type PhysicalVolume struct {
	// Name of the lvm physical volume.
	Name string

	// UUID denotes a unique identity of a lvm physical volume.
	UUID string

	// Size specifies the total size of physical volume in bytes
	Size resource.Quantity

	// DeviceSize specifies the size of underlying device in bytes
	DeviceSize resource.Quantity

	// MetadataSize specifies the size of smallest metadata area on this device in bytes
	MetadataSize resource.Quantity

	// MetadataFree specifies the free metadata area space on the device in bytes
	MetadataFree resource.Quantity

	// Free specifies the physical volume unallocated space in bytes
	Free resource.Quantity

	// Used specifies the physical volume allocated space in bytes
	Used resource.Quantity

	// Allocatable indicates whether the device can be used for allocation
	Allocatable string

	// Missing indicates whether the device is missing in the system
	Missing string

	// InUse indicates whether or not the physical volume is in use
	InUse string

	// Name of the volume group which uses this physical volume
	VGName string
}

PhysicalVolume specifies attributes of a given pv that exists on the node.

func ListLVMPhysicalVolume added in v0.8.0

func ListLVMPhysicalVolume() ([]PhysicalVolume, error)

ListLVMPhysicalVolume invokes `pvs` to list all the available LVM physical volumes in the node.

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