cache

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2021 License: Apache-2.0 Imports: 7 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AllocatedUnit

type AllocatedUnit struct {
	NodeName   string
	VolumeType localtype.VolumeType
	Requested  int64 // requested size from pvc
	Allocated  int64 // actual allocated size for the pvc
	VgName     string
	Device     string
	MountPoint string
	PVCName    string
}

type BindingMap

type BindingMap map[string]*AllocatedUnit

pvc and binding info mapping

func (BindingMap) IsPVCExists

func (bm BindingMap) IsPVCExists(pvc string) bool

type ClusterInfo

type ClusterInfo struct {
	Nodes map[string]*NodeCache `json:"Nodes,omitempty"`
	// Only records the requested open-local unit to avoid duplicate scheduling request
	BindingInfo BindingMap `json:"bindingInfo,omitempty"`
	// PvcMapping records requested pod and pvc mapping
	PvcMapping *PodPvcMapping `json:"pvcMapping"`
}

type ClusterNodeCache

type ClusterNodeCache struct {
	ClusterInfo
	// contains filtered or unexported fields
}

ClusterNodeCache maintains mapping of allocated local PVs and Nodes

func NewClusterNodeCache

func NewClusterNodeCache() *ClusterNodeCache

func (*ClusterNodeCache) AddNodeCache

func (c *ClusterNodeCache) AddNodeCache(nodeLocal *nodelocalstorage.NodeLocalStorage) *NodeCache

func (*ClusterNodeCache) Assume

func (c *ClusterNodeCache) Assume(units []AllocatedUnit) (err error)

Assume updates the allocated units into cache immediately to avoid any potential resource over allocated

func (*ClusterNodeCache) GetNodeCache

func (c *ClusterNodeCache) GetNodeCache(nodeName string) *NodeCache

func (*ClusterNodeCache) GetNodeNameFromPV

func (c *ClusterNodeCache) GetNodeNameFromPV(pv *corev1.PersistentVolume) string

func (*ClusterNodeCache) SetNodeCache

func (c *ClusterNodeCache) SetNodeCache(nodeCache *NodeCache) *NodeCache

func (*ClusterNodeCache) UpdateNodeCache

func (c *ClusterNodeCache) UpdateNodeCache(nodeLocal *nodelocalstorage.NodeLocalStorage) *NodeCache

type ExclusiveResource

type ExclusiveResource struct {
	Name      string              `json:"name"`
	Device    string              `json:"device"`
	Capacity  int64               `json:"capacity,string"`
	MediaType localtype.MediaType `json:"mediaType"`
	// "IsAllocated = true" means the disk is used by PV
	IsAllocated bool `json:"isAllocated,string"`
}

type NodeCache

type NodeCache struct {
	NodeInfo
	// contains filtered or unexported fields
}

func NewNodeCache

func NewNodeCache(nodeName string) *NodeCache

func NewNodeCacheFromStorage

func NewNodeCacheFromStorage(nodeLocal *nodelocalstorage.NodeLocalStorage) *NodeCache

func (*NodeCache) AddLVM

func (nc *NodeCache) AddLVM(pv *corev1.PersistentVolume) error

AddLVM add lvm PV to cache note: this function does not handle pv update event

func (*NodeCache) AddLocalDevice

func (nc *NodeCache) AddLocalDevice(pv *corev1.PersistentVolume) error

func (*NodeCache) AddLocalMountPoint

func (nc *NodeCache) AddLocalMountPoint(pv *corev1.PersistentVolume) error

func (*NodeCache) IsLocalPVExist added in v0.2.2

func (nc *NodeCache) IsLocalPVExist(kind pkg.VolumeType, resourceName string) bool

IsLocalPVExist will check whether PV exists in LocalPV according to resourceName and kind

func (*NodeCache) RemoveLVM

func (nc *NodeCache) RemoveLVM(pv *corev1.PersistentVolume) error

func (*NodeCache) RemoveLocalDevice

func (nc *NodeCache) RemoveLocalDevice(pv *corev1.PersistentVolume) error

func (*NodeCache) RemoveLocalMountPoint

func (nc *NodeCache) RemoveLocalMountPoint(pv *corev1.PersistentVolume) error

func (*NodeCache) UpdateLVM

func (nc *NodeCache) UpdateLVM(old, pv *corev1.PersistentVolume) error

UpdateLVM updates lvm PV to cache note: this function does not handle pv add event

func (*NodeCache) UpdateNodeInfo

func (nc *NodeCache) UpdateNodeInfo(nodeLocal *nodelocalstorage.NodeLocalStorage) *NodeCache

type NodeInfo

type NodeInfo struct {
	NodeName string
	// VGs is the volume group
	VGs         map[ResourceName]SharedResource
	MountPoints map[ResourceName]ExclusiveResource
	// Devices only contains the whitelist raw devices
	Devices      map[ResourceName]ExclusiveResource
	AllocatedNum int64
	LocalPVs     map[string]corev1.PersistentVolume
}

type PodPvcMapping

type PodPvcMapping struct {
	// PodPvcStatus count ref for a specified pod
	// string => pod namespace/name
	// PvcStatus => pvc status
	// podName <=> pvcStatusInfo
	PodPvcInfo map[string]PvcStatusInfo
	// store the pvc to pod mapping for faster index by pvc
	// pvcName <=> podName
	PvcPod map[string]string
}

func NewPodPvcMapping

func NewPodPvcMapping() *PodPvcMapping

func (*PodPvcMapping) DeletePod

func (p *PodPvcMapping) DeletePod(podName string, pvcs []*corev1.PersistentVolumeClaim)

DeletePod deletes pod and all its pvcs for cache

func (*PodPvcMapping) DeletePvc

func (p *PodPvcMapping) DeletePvc(pvc *corev1.PersistentVolumeClaim)

DeletePvc deletes pvc key from change

func (*PodPvcMapping) IsPodPvcReady

func (p *PodPvcMapping) IsPodPvcReady(pvc *corev1.PersistentVolumeClaim) bool

IsPodPvcReady defines whether a pvc and its related pvcs are ready(with selected node) for pv provisioning; it returns true only when all pvcs of a pod are marked as ready for provisioning.

func (*PodPvcMapping) PutPod

func (p *PodPvcMapping) PutPod(podName string, pvcs []*corev1.PersistentVolumeClaim)

PutPod adds or updates the pod and pvc mapping it assures they are open-local type and contain all the requested PVCs

func (*PodPvcMapping) PutPvc

func (p *PodPvcMapping) PutPvc(pvc *corev1.PersistentVolumeClaim)

PutPvc adds or updates the pod and pvc mapping it assure the pvcs contains all the requested PVCs

type PvcStatusInfo

type PvcStatusInfo map[string]bool

PvcStatus refers to the pvc(for a pod) and its status of selected node string => pvc namespace/name bool => true/false true means volume.kubernetes.io/selected-node

func NewPvcStatusInfo

func NewPvcStatusInfo() PvcStatusInfo

type ResourceName

type ResourceName string

type ResourceType

type ResourceType string
const (
	SharedResourceType    ResourceType = "Shared"
	ExclusiveResourceType ResourceType = "Exclusive"
)

type SharedResource

type SharedResource struct {
	Name      string `json:"name"`
	Capacity  int64  `json:"capacity,string"`
	Requested int64  `json:"requested,string"`
}

Jump to

Keyboard shortcuts

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