zfs

package
v1.9.3 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2021 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// OpenEBSNamespaceKey is the environment variable to get openebs namespace
	//
	// This environment variable is set via kubernetes downward API
	OpenEBSNamespaceKey string = "OPENEBS_NAMESPACE"
	// GoogleAnalyticsKey This environment variable is set via env
	GoogleAnalyticsKey string = "OPENEBS_IO_ENABLE_ANALYTICS"
	// ZFSFinalizer for the ZfsVolume CR
	ZFSFinalizer string = "zfs.openebs.io/finalizer"
	// ZFSVolKey for the ZfsSnapshot CR to store Persistence Volume name
	ZFSVolKey string = "openebs.io/persistent-volume"
	// ZFSSrcVolKey key for the source Volume name
	ZFSSrcVolKey string = "openebs.io/source-volume"
	// PoolNameKey is key for ZFS pool name
	PoolNameKey string = "openebs.io/poolname"
	// ZFSNodeKey will be used to insert Label in ZfsVolume CR
	ZFSNodeKey string = "kubernetes.io/nodename"
	// ZFSTopologyKey is supported topology key for the zfs driver
	ZFSTopologyKey string = "openebs.io/nodeid"
	// ZFSTopoNodenameKey is supported topology key for the zfs driver
	ZFSTopoNodenameKey string = "openebs.io/nodename"
	// ZFSStatusPending shows object has not handled yet
	ZFSStatusPending string = "Pending"
	// ZFSStatusFailed shows object operation has failed
	ZFSStatusFailed string = "Failed"
	// ZFSStatusReady shows object has been processed
	ZFSStatusReady string = "Ready"
	// OpenEBSCasTypeKey for the cas-type label
	OpenEBSCasTypeKey string = "openebs.io/cas-type"
	// ZFSCasTypeName for the name of the cas-type
	ZFSCasTypeName string = "localpv-zfs"
)
View Source
const (
	ZFSDevPath = "/dev/zvol/"
	FSTypeZFS  = "zfs"
)

zfs related constants

View Source
const (
	ZFSVolCmd      = "zfs"
	ZFSCreateArg   = "create"
	ZFSCloneArg    = "clone"
	ZFSDestroyArg  = "destroy"
	ZFSSetArg      = "set"
	ZFSGetArg      = "get"
	ZFSListArg     = "list"
	ZFSSnapshotArg = "snapshot"
	ZFSSendArg     = "send"
	ZFSRecvArg     = "recv"
)

zfs command related constants

View Source
const (
	VolTypeDataset = "DATASET"
	VolTypeZVol    = "ZVOL"
)

constants to define volume type

Variables

View Source
var (
	// OpenEBSNamespace is openebs system namespace
	OpenEBSNamespace 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 CreateBackup added in v1.0.0

func CreateBackup(bkp *apis.ZFSBackup) error

CreateBackup creates the backup

func CreateClone

func CreateClone(vol *apis.ZFSVolume) error

CreateClone creates clone for the zvol/dataset as per info provided in ZFSVolume object

func CreateRestore added in v1.0.0

func CreateRestore(rstr *apis.ZFSRestore) error

CreateRestore creates the restore

func CreateSnapshot

func CreateSnapshot(snap *apis.ZFSSnapshot) error

CreateSnapshot creates the zfs volume snapshot

func CreateVolume

func CreateVolume(vol *apis.ZFSVolume) error

CreateVolume creates the zvol/dataset as per info provided in ZFSVolume object

func DeleteSnapshot

func DeleteSnapshot(snapname string) (err error)

DeleteSnapshot deletes the corresponding ZFSSnapshot CR

func DeleteVolume

func DeleteVolume(volumeID string) (err error)

DeleteVolume deletes the corresponding ZFSVol CR

func DestoryBackup added in v1.0.0

func DestoryBackup(bkp *apis.ZFSBackup) error

DestoryBackup deletes the snapshot created

func DestroySnapshot

func DestroySnapshot(snap *apis.ZFSSnapshot) error

DestroySnapshot deletes the zfs volume snapshot

func DestroyVolume

func DestroyVolume(vol *apis.ZFSVolume) error

DestroyVolume deletes the zfs volume

func FormatAndMountZvol

func FormatAndMountZvol(devicePath string, mountInfo *MountInfo) error

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

func GetNodeID added in v1.7.0

func GetNodeID(nodename string) (string, error)

func GetUserFinalizers added in v1.6.0

func GetUserFinalizers(finalizers []string) []string

GetUserFinalizers returns all the finalizers present on the ZFSVolume object execpt the one owned by ZFS node daemonset. We also need to ignore the foregroundDeletion finalizer as this will be present becasue of the foreground cascading deletion

func GetVolList

func GetVolList(volumeID string) (*apis.ZFSVolumeList, error)

GetVolList fetches the current Published Volume list

func GetVolume

func GetVolume(volumeID string) (*apis.ZFSVolume, error)

GetVolume the corresponding ZFSVolume CR

func GetVolumeDevPath

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

GetVolumeDevPath returns devpath for the given volume

func GetVolumeProperty

func GetVolumeProperty(vol *apis.ZFSVolume, prop string) (string, error)

GetVolumeProperty gets zfs properties for the volume

func GetVolumeType

func GetVolumeType(fstype string) string

GetVolumeType returns the volume type whether it is a zvol or dataset

func GetZFSSnapshot

func GetZFSSnapshot(snapID string) (*apis.ZFSSnapshot, error)

GetZFSSnapshot fetches the given ZFSSnapshot

func GetZFSSnapshotStatus

func GetZFSSnapshotStatus(snapID string) (string, error)

GetZFSSnapshotStatus returns ZFSSnapshot status

func GetZFSVolume

func GetZFSVolume(volumeID string) (*apis.ZFSVolume, error)

GetZFSVolume fetches the given ZFSVolume

func GetZFSVolumeState added in v0.8.0

func GetZFSVolumeState(volID string) (string, string, error)

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

func IsVolumeReady added in v1.6.0

func IsVolumeReady(vol *apis.ZFSVolume) bool

IsVolumeReady returns true if volume is Ready

func ListZFSPool added in v1.8.0

func ListZFSPool() ([]apis.Pool, error)

ListZFSPool invokes `zfs list` to list all the available pools in the node.

func MountBlock

func MountBlock(vol *apis.ZFSVolume, mountinfo *MountInfo) error

MountBlock mounts the block disk to the specified path

func MountDataset

func MountDataset(vol *apis.ZFSVolume, mount *MountInfo) error

MountDataset mounts the zfs dataset to the specified path

func MountFilesystem

func MountFilesystem(vol *apis.ZFSVolume, mount *MountInfo) error

MountFilesystem mounts the disk to the specified path

func MountZFSDataset

func MountZFSDataset(vol *apis.ZFSVolume, mountpath string) error

MountZFSDataset mounts the dataset to the given mountpoint

func MountZvol

func MountZvol(vol *apis.ZFSVolume, mount *MountInfo) error

MountZvol mounts the disk to the specified path

func PropertyChanged

func PropertyChanged(oldVol *apis.ZFSVolume, newVol *apis.ZFSVolume) bool

PropertyChanged return whether volume property is changed

func ProvisionSnapshot

func ProvisionSnapshot(
	snap *apis.ZFSSnapshot,
) error

ProvisionSnapshot creates a ZFSSnapshot CR, watcher for zvc is present in CSI agent

func ProvisionVolume

func ProvisionVolume(
	ctx context.Context,
	vol *apis.ZFSVolume,
) (bool, error)

ProvisionVolume creates a ZFSVolume(zv) CR, watcher for zvc is present in CSI agent

func RemoveBkpFinalizer added in v1.0.0

func RemoveBkpFinalizer(bkp *apis.ZFSBackup) error

RemoveBkpFinalizer removes finalizer from ZFSBackup CR

func RemoveSnapFinalizer

func RemoveSnapFinalizer(snap *apis.ZFSSnapshot) error

RemoveSnapFinalizer removes finalizer from ZFSSnapshot CR

func RemoveVolumeFinalizer added in v1.6.0

func RemoveVolumeFinalizer(vol *apis.ZFSVolume) error

RemoveVolumeFinalizer removes finalizer from ZFSVolume CR

func ResizeExtn

func ResizeExtn(devpath string) error

ResizeExtn can be used to run a resize command on the ext2/3/4 filesystem to expand the filesystem to the actual size of the device

func ResizeVolume

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

ResizeVolume resizes the zfs volume

func ResizeXFS

func ResizeXFS(path string) error

ResizeXFS can be used to run a resize command on the xfs filesystem to expand the filesystem to the actual size of the device

func ResizeZFSVolume

func ResizeZFSVolume(vol *apis.ZFSVolume, mountpath string, resizefs bool) error

ResizeZFSVolume resize volume

func SetDatasetLegacyMount added in v0.8.0

func SetDatasetLegacyMount(vol *apis.ZFSVolume) error

SetDatasetLegacyMount sets the dataset mountpoint to legacy if not set

func SetDatasetMountProp

func SetDatasetMountProp(volume string, mountpath string) error

SetDatasetMountProp sets mountpoint for the volume

func SetVolumeProp

func SetVolumeProp(vol *apis.ZFSVolume) error

SetVolumeProp sets the volume property

func UmountVolume

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

UmountVolume unmounts the volume and the corresponding mount path is removed

func UpdateBkpInfo added in v1.0.0

func UpdateBkpInfo(bkp *apis.ZFSBackup, status apis.ZFSBackupStatus) error

UpdateBkpInfo updates the backup info with the status

func UpdateRestoreInfo added in v1.0.0

func UpdateRestoreInfo(rstr *apis.ZFSRestore, status apis.ZFSRestoreStatus) error

UpdateRestoreInfo updates the rstr info with the status

func UpdateSnapInfo

func UpdateSnapInfo(snap *apis.ZFSSnapshot) error

UpdateSnapInfo updates ZFSSnapshot CR with node id and finalizer

func UpdateZvolInfo

func UpdateZvolInfo(vol *apis.ZFSVolume, status string) error

UpdateZvolInfo updates ZFSVolume CR with node id and finalizer

Types

type MountInfo added in v1.1.0

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 ZFSVolume

Jump to

Keyboard shortcuts

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