util

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GiB = 1024 * 1024 * 1024
)

Variables

This section is empty.

Functions

func BytesToGiB

func BytesToGiB(volumeSizeBytes int64) int64

BytesToGiB conversts Bytes to GiB

func CleanupMountPoint

func CleanupMountPoint(mountPath string, mounter mount.Interface, extensiveMountPointCheck bool) error

CleanupMountPoint unmounts the given path and deletes the remaining directory if successful. if extensiveMountPointCheck is true IsNotMountPoint will be called instead of IsLikelyNotMountPoint. IsNotMountPoint is more expensive but properly handles bind mounts within the same fs.

func GetK8sNamespace

func GetK8sNamespace() string

GetK8sNamespace returns pod namespace. if pod namespace is empty it returns default namespace

func GiBToBytes

func GiBToBytes(volumeSizeGiB int64) int64

GiBToBytes converts GiB to Bytes

func IsCorruptedMnt

func IsCorruptedMnt(err error) bool

IsCorruptedMnt return true if err is about corrupted mount point

func NewK8sClient

func NewK8sClient() *k8s.Clientset

NewK8sClient create kubernetes client

func PathExists

func PathExists(path string) (bool, error)

TODO: clean this up to use pkg/util/file/FileExists PathExists returns true if the specified path exists.

func RoundUpBytes

func RoundUpBytes(volumeSizeBytes int64) int64

RoundUpBytes rounds up the volume size in bytes upto multiplications of GiB in the unit of Bytes

func RoundUpGiB

func RoundUpGiB(volumeSizeBytes int64) int64

RoundUpGiB rounds up the volume size in bytes upto multiplications of GiB in the unit of GiB

Types

type CacheEntryNotFound

type CacheEntryNotFound struct {
	// contains filtered or unexported fields
}

CacheEntryNotFound is an error type for "Not Found" cache errors

type CachePersister

type CachePersister interface {
	Create(identifier string, data interface{}) error
	Get(identifier string, data interface{}) error
	ForAll(pattern string, destObj interface{}, f ForAllFunc) error
	Delete(identifier string) error
}

CachePersister interface implemented for store

func NewCachePersister

func NewCachePersister() CachePersister

NewCachePersister returns K8sCachePersister

type ForAllFunc

type ForAllFunc func(identifier string) error

ForAllFunc is a unary predicate for visiting all cache entries matching the `pattern' in CachePersister's ForAll function.

type Idempotent

type Idempotent struct {
	// contains filtered or unexported fields
}

Idempotent is a struct used to manage in flight requests.

func NewIdempotent

func NewIdempotent() *Idempotent

NewIdempotent instanciates a Idempotent structures.

func (*Idempotent) Delete

func (idem *Idempotent) Delete(h RequestItem)

func (*Idempotent) Insert

func (idem *Idempotent) Insert(entry RequestItem) bool

type K8sCMCache

type K8sCMCache struct {
	Client    *k8s.Clientset
	Namespace string
}

K8sCMCache to store metadata

func (*K8sCMCache) Create

func (k8scm *K8sCMCache) Create(identifier string, data interface{}) error

Create stores the metadata in configmaps with identifier name

func (*K8sCMCache) Delete

func (k8scm *K8sCMCache) Delete(identifier string) error

Delete deletes the metadata in configmaps with identifier name

func (*K8sCMCache) ForAll

func (k8scm *K8sCMCache) ForAll(pattern string, destObj interface{}, f ForAllFunc) error

ForAll list the metadata in configmaps and filters outs based on the pattern

func (*K8sCMCache) Get

func (k8scm *K8sCMCache) Get(identifier string, data interface{}) error

Get retrieves the metadata in configmaps with identifier name

type RequestItem

type RequestItem interface {
	// The CSI data types are generated using a protobuf.
	// The generated structures are guaranteed to implement the Stringer interface.
	// Example: https://github.com/container-storage-interface/spec/blob/master/lib/go/csi/csi.pb.go#L3508
	// We can use the generated string as the key of our internal inflight database of requests.
	String() string
}

RequestItem is the interface required to manage in flight requests.

Jump to

Keyboard shortcuts

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