Documentation ¶
Index ¶
- Constants
- Variables
- func CheckVolumeExists(vol *apis.LVMVolume) (bool, error)
- func CreateSnapshot(snap *apis.LVMSnapshot) error
- func CreateVolume(vol *apis.LVMVolume) error
- func DeleteSnapshot(snapName string) error
- func DeleteVolume(volumeID string) (err error)
- func DestroySnapshot(snap *apis.LVMSnapshot) error
- func DestroyVolume(vol *apis.LVMVolume) error
- func FormatAndMountVol(devicePath string, mountInfo *MountInfo) error
- func GetLVMSnapshot(snapID string) (*apis.LVMSnapshot, error)
- func GetLVMSnapshotStatus(snapID string) (string, error)
- func GetLVMVolume(volumeID string) (*apis.LVMVolume, error)
- func GetLVMVolumeState(volID string) (string, string, error)
- func GetSnapshotForVolume(volumeID string) (*apis.LVMSnapshotList, error)
- func GetVolumeDevPath(vol *apis.LVMVolume) (string, error)
- func ListLVMVolumeGroup(reloadCache bool) ([]apis.VolumeGroup, error)
- func MountBlock(vol *apis.LVMVolume, mountinfo *MountInfo, podLVInfo *PodLVInfo) error
- func MountFilesystem(vol *apis.LVMVolume, mount *MountInfo, podinfo *PodLVInfo) error
- func MountVolume(vol *apis.LVMVolume, mount *MountInfo, podLVInfo *PodLVInfo) error
- func ProvisionSnapshot(snap *apis.LVMSnapshot) error
- func ProvisionVolume(vol *apis.LVMVolume) (*apis.LVMVolume, error)
- func ReloadLVMMetadataCache() error
- func RemoveSnapFinalizer(snap *apis.LVMSnapshot) error
- func RemoveVolFinalizer(vol *apis.LVMVolume) error
- func ResizeLVMVolume(vol *apis.LVMVolume, resizefs bool) error
- func ResizeVolume(vol *apis.LVMVolume, newSize int64) error
- func SetIORateLimits(config *config.Config)
- func UmountVolume(vol *apis.LVMVolume, targetPath string) error
- func UpdateSnapInfo(snap *apis.LVMSnapshot) error
- func UpdateVolGroup(vol *apis.LVMVolume, vgName string) (*apis.LVMVolume, error)
- func UpdateVolInfo(vol *apis.LVMVolume, state string) error
- func WaitForLVMVolumeDestroy(ctx context.Context, volumeID string) error
- func WaitForLVMVolumeProcessed(ctx context.Context, volumeID string) (*apis.LVMVolume, error)
- type ExecError
- type LogicalVolume
- type MountInfo
- type PhysicalVolume
- type PodLVInfo
Constants ¶
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
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
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
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 ¶
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 )
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
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 ¶
CreateVolume creates the lvm volume
func DeleteSnapshot ¶ added in v0.2.0
DeleteSnapshot deletes the LVMSnapshot CR
func DeleteVolume ¶
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 ¶
DestroyVolume deletes the lvm volume
func FormatAndMountVol ¶
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
GetLVMSnapshotStatus returns the status of LVMSnapshot
func GetLVMVolume ¶
GetLVMVolume fetches the given LVMVolume
func GetLVMVolumeState ¶
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 ¶
GetVolumeDevPath returns devpath for the given volume
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
MountBlock mounts the block disk to the specified path
func MountFilesystem ¶
MountFilesystem mounts the disk to the specified path
func MountVolume ¶
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 ¶
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 ¶
RemoveVolFinalizer adds finalizer to LVMVolume CR
func ResizeLVMVolume ¶
ResizeLVMVolume resizes the underlying LVM volume and FS if resizefs is set to true Note:
- Triggering `lvextend <dev_path> -L <size> -r` multiple times with same size will not return any errors
- Triggering `lvextend <dev_path> -L <size>` more than one time will cause errors
func ResizeVolume ¶
ResizeVolume resizes the lvm volume
func SetIORateLimits ¶ added in v0.3.0
SetIORateLimits sets io limit rates for the volume group (prefixes) provided in config
func UmountVolume ¶
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
UpdateVolGroup updates LVMVolume CR with volGroup name.
func UpdateVolInfo ¶
UpdateVolInfo updates LVMVolume CR with node id and finalizer
func WaitForLVMVolumeDestroy ¶ added in v0.3.0
WaitForLVMVolumeDestroy waits till the lvm volume gets deleted.
Types ¶
type ExecError ¶ added in v0.3.0
ExecError holds the process output along with underlying error returned by exec.CombinedOutput function.
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.