utils

package
v0.5.4-dev-ipv6 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2022 License: Apache-2.0 Imports: 28 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckMountPointOptions

func CheckMountPointOptions(mp *nodelocalstorage.MountPoint) bool

CheckDiskOptions excludes mp which is readyonly or with unsupported fs type

func ContainInlineVolumes added in v0.5.0

func ContainInlineVolumes(pod *corev1.Pod) (contain bool, node string)

func ContainsProvisioner

func ContainsProvisioner(name string) bool

func ContainsSnapshotPVC

func ContainsSnapshotPVC(claims []*corev1.PersistentVolumeClaim) (contain bool)

func ContainsString

func ContainsString(s []string, e string) bool

Contains method for a slice

func Format

func Format(source, fsType string) error

Format formats the source with the given filesystem type

func GetAddedAndRemovedItems

func GetAddedAndRemovedItems(newList, oldList []string) (addedItems, unchangedItems, removedItems []string)

func GetDeviceNameFromCsiPV

func GetDeviceNameFromCsiPV(pv *corev1.PersistentVolume) string

GetDeviceNameFromCsiPV extracts Device Name from open-local csi PV via VolumeAttributes

func GetInlineVolumeInfoFromParam added in v0.5.0

func GetInlineVolumeInfoFromParam(attributes map[string]string) (vgName string, size int64)

func GetMetrics

func GetMetrics(path string) (*csilib.NodeGetVolumeStatsResponse, error)

GetMetrics get path metric

func GetMountPointFromCsiPV

func GetMountPointFromCsiPV(pv *corev1.PersistentVolume) string

GetMountPointFromCsiPV extracts MountPoint from open-local csi PV via VolumeAttributes

func GetPVCRequested

func GetPVCRequested(pvc *corev1.PersistentVolumeClaim) int64

func GetPVFromBoundPVC

func GetPVFromBoundPVC(pvc *corev1.PersistentVolumeClaim) (name string)

func GetPVSize

func GetPVSize(pv *corev1.PersistentVolume) int64

func GetPVStorageSize

func GetPVStorageSize(pv *corev1.PersistentVolume) int64

func GetVGNameFromCsiPV

func GetVGNameFromCsiPV(pv *corev1.PersistentVolume) string

GetVGNameFromCsiPV extracts vgName from open-local csi PV via VolumeAttributes

func GetVGRequested

func GetVGRequested(localPVs map[string]corev1.PersistentVolume, vgName string) (requested int64)

func HashSpec

func HashSpec(storage *nodelocalstorage.NodeLocalStorage) uint64

func HashStorageSpec

func HashStorageSpec(obj interface{}) uint64

func HashWithoutState

func HashWithoutState(storage *nodelocalstorage.NodeLocalStorage) uint64

HashWithoutState remove the state field then compare

func HttpJSON

func HttpJSON(w http.ResponseWriter, code int, result interface{})

func HttpResponse

func HttpResponse(w http.ResponseWriter, code int, msg []byte)

func IsDirEmpty

func IsDirEmpty(name string) (bool, error)

IsDirEmpty return status of dir empty or not

func IsEmpty

func IsEmpty(r string) bool

func IsFormatted

func IsFormatted(source string) (bool, error)

IsFormatted checks whether the source device is formatted or not. It returns true if the source device is already formatted.

func IsLocalPV

func IsLocalPV(pv *corev1.PersistentVolume) (isLocalPV bool, node string)

func IsLocalPVC

func IsLocalPVC(claim *corev1.PersistentVolumeClaim, p storagev1informers.Interface, containReadonlySnapshot bool) (bool, localtype.VolumeType)

func IsLocalSnapshotPVC added in v0.2.2

func IsLocalSnapshotPVC(claim *corev1.PersistentVolumeClaim) bool

func IsMounted

func IsMounted(mountPath string) bool

IsMounted return status of mount operation

func IsOpenLocalPV added in v0.2.2

func IsOpenLocalPV(pv *corev1.PersistentVolume, p storagev1informers.Interface, c corev1informers.Interface, containReadonlySnapshot bool) (bool, localtype.VolumeType)

func IsSnapshotPVC

func IsSnapshotPVC(claim *corev1.PersistentVolumeClaim) bool

func LocalPVType added in v0.2.2

func LocalPVType(sc *storagev1.StorageClass) localtype.VolumeType

func NeedSkip added in v0.3.0

func NeedSkip(args schedulerapi.ExtenderArgs) bool

func PVCName

func PVCName(storageObj interface{}) string

func PodName

func PodName(pod *corev1.Pod) string

func PodPvcAllowReschedule

func PodPvcAllowReschedule(pvcs []*corev1.PersistentVolumeClaim, fakeNow *time.Time) bool

PodPvcAllowReschedule returns true if any of pvcs has in pending status for more than 5 minutes the fakeNow is parameter for unit testing

func PvcContainsSelectedNode

func PvcContainsSelectedNode(pvc *corev1.PersistentVolumeClaim) bool

func Run

func Run(cmd string) (string, error)

Run run shell command

func SliceEquals

func SliceEquals(src interface{}, dst interface{}) bool

func StringsContains

func StringsContains(array []string, val string) (index int)

StringsContains check val exist in array

func WordSepNormalizeFunc

func WordSepNormalizeFunc(f *pflag.FlagSet, name string) pflag.NormalizedName

WordSepNormalizeFunc changes all flags that contain "_" separators

Types

type CommandRunFunc

type CommandRunFunc func(cmd string) (string, error)

CommandRunFunc define the run function in utils for ut

type Mounter

type Mounter interface {
	// If the folder doesn't exist, it will call 'mkdir -p'
	EnsureFolder(target string) error
	// If the block doesn't exist, create it
	EnsureBlock(target string) error
	// Format formats the source with the given filesystem type
	Format(source, fsType string) error

	// Mount mounts source to target with the given fstype and options.
	Mount(source, target, fsType string, options ...string) error

	// Mount mounts source to target for block file.
	MountBlock(source, target string, options ...string) error
	// Unmount unmounts the given target
	Unmount(target string) error

	// IsFormatted checks whether the source device is formatted or not. It
	// returns true if the source device is already formatted.
	IsFormatted(source string) (bool, error)

	// IsMounted checks whether the target path is a correct mount (i.e:
	// propagated). It returns true if it's mounted. An error is returned in
	// case of system errors or if it's mounted incorrectly.
	IsMounted(target string) (bool, error)

	SafePathRemove(target string) error

	HasMountRefs(mountPath string, mountRefs []string) bool
}

Mounter is responsible for formatting and mounting volumes

func NewMounter

func NewMounter() Mounter

NewMounter returns a new mounter instance

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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