scheduling

package
v1.18.19-rc.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2021 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AssumeCache

type AssumeCache interface {
	// Assume updates the object in-memory only
	Assume(obj interface{}) error

	// Restore the informer cache's version of the object
	Restore(objName string)

	// Get the object by name
	Get(objName string) (interface{}, error)

	// Get the API object by name
	GetAPIObj(objName string) (interface{}, error)

	// List all the objects in the cache
	List(indexObj interface{}) []interface{}
}

AssumeCache is a cache on top of the informer that allows for updating objects outside of informer events and also restoring the informer cache's version of the object. Objects are assumed to be Kubernetes API objects that implement meta.Interface

func NewAssumeCache

func NewAssumeCache(informer cache.SharedIndexInformer, description, indexName string, indexFunc cache.IndexFunc) AssumeCache

NewAssumeCache creates an assume cache for general objects.

type ConflictReason added in v1.18.0

type ConflictReason string

ConflictReason is used for the special strings which explain why volume binding is impossible for a node.

const (
	// ErrReasonBindConflict is used for VolumeBindingNoMatch predicate error.
	ErrReasonBindConflict ConflictReason = "node(s) didn't find available persistent volumes to bind"
	// ErrReasonNodeConflict is used for VolumeNodeAffinityConflict predicate error.
	ErrReasonNodeConflict ConflictReason = "node(s) had volume node affinity conflict"
	// ErrUnboundImmediatePVC is used when the pod has an unbound PVC in immedate binding mode.
	ErrUnboundImmediatePVC ConflictReason = "pod has unbound immediate PersistentVolumeClaims"
	// ErrReasonPVNotExist is used when a PVC can't find the bound persistent volumes"
	ErrReasonPVNotExist = "pvc(s) bound to non-existent pv(s)"
)

type ConflictReasons added in v1.18.0

type ConflictReasons []ConflictReason

ConflictReasons contains all reasons that explain why volume binding is impossible for a node.

func (ConflictReasons) Len added in v1.18.0

func (reasons ConflictReasons) Len() int

func (ConflictReasons) Less added in v1.18.0

func (reasons ConflictReasons) Less(i, j int) bool

func (ConflictReasons) Swap added in v1.18.0

func (reasons ConflictReasons) Swap(i, j int)

type FakeVolumeBinder

type FakeVolumeBinder struct {
	AssumeCalled bool
	BindCalled   bool
	// contains filtered or unexported fields
}

FakeVolumeBinder represents a fake volume binder for testing.

func NewFakeVolumeBinder

func NewFakeVolumeBinder(config *FakeVolumeBinderConfig) *FakeVolumeBinder

NewFakeVolumeBinder sets up all the caches needed for the scheduler to make topology-aware volume binding decisions.

func (*FakeVolumeBinder) AssumePodVolumes

func (b *FakeVolumeBinder) AssumePodVolumes(assumedPod *v1.Pod, nodeName string) (bool, error)

AssumePodVolumes implements SchedulerVolumeBinder.AssumePodVolumes.

func (*FakeVolumeBinder) BindPodVolumes

func (b *FakeVolumeBinder) BindPodVolumes(assumedPod *v1.Pod) error

BindPodVolumes implements SchedulerVolumeBinder.BindPodVolumes.

func (*FakeVolumeBinder) DeletePodBindings added in v1.18.0

func (b *FakeVolumeBinder) DeletePodBindings(pod *v1.Pod)

DeletePodBindings implements SchedulerVolumeBinder.DeletePodBindings.

func (*FakeVolumeBinder) FindPodVolumes

func (b *FakeVolumeBinder) FindPodVolumes(pod *v1.Pod, node *v1.Node) (reasons ConflictReasons, err error)

FindPodVolumes implements SchedulerVolumeBinder.FindPodVolumes.

func (*FakeVolumeBinder) GetBindingsCache

func (b *FakeVolumeBinder) GetBindingsCache() PodBindingCache

GetBindingsCache implements SchedulerVolumeBinder.GetBindingsCache.

type FakeVolumeBinderConfig

type FakeVolumeBinderConfig struct {
	AllBound    bool
	FindReasons ConflictReasons
	FindErr     error
	AssumeErr   error
	BindErr     error
}

FakeVolumeBinderConfig holds configurations for fake volume binder.

type InTreeToCSITranslator added in v1.17.0

type InTreeToCSITranslator interface {
	IsPVMigratable(pv *v1.PersistentVolume) bool
	GetInTreePluginNameFromSpec(pv *v1.PersistentVolume, vol *v1.Volume) (string, error)
	TranslateInTreePVToCSI(pv *v1.PersistentVolume) (*v1.PersistentVolume, error)
}

InTreeToCSITranslator contains methods required to check migratable status and perform translations from InTree PV's to CSI

type PVAssumeCache

type PVAssumeCache interface {
	AssumeCache

	GetPV(pvName string) (*v1.PersistentVolume, error)
	GetAPIPV(pvName string) (*v1.PersistentVolume, error)
	ListPVs(storageClassName string) []*v1.PersistentVolume
}

PVAssumeCache is a AssumeCache for PersistentVolume objects

func NewPVAssumeCache

func NewPVAssumeCache(informer cache.SharedIndexInformer) PVAssumeCache

NewPVAssumeCache creates a PV assume cache.

type PVCAssumeCache

type PVCAssumeCache interface {
	AssumeCache

	// GetPVC returns the PVC from the cache with given pvcKey.
	// pvcKey is the result of MetaNamespaceKeyFunc on PVC obj
	GetPVC(pvcKey string) (*v1.PersistentVolumeClaim, error)
	GetAPIPVC(pvcKey string) (*v1.PersistentVolumeClaim, error)
}

PVCAssumeCache is a AssumeCache for PersistentVolumeClaim objects

func NewPVCAssumeCache

func NewPVCAssumeCache(informer cache.SharedIndexInformer) PVCAssumeCache

NewPVCAssumeCache creates a PVC assume cache.

type PodBindingCache

type PodBindingCache interface {
	// UpdateBindings will update the cache with the given bindings for the
	// pod and node.
	UpdateBindings(pod *v1.Pod, node string, bindings []*bindingInfo, provisionings []*v1.PersistentVolumeClaim)

	// ClearBindings will clear the cached bindings for the given pod and node.
	ClearBindings(pod *v1.Pod, node string)

	// GetBindings will return the cached bindings for the given pod and node.
	// A nil return value means that the entry was not found. An empty slice
	// means that no binding operations are needed.
	GetBindings(pod *v1.Pod, node string) []*bindingInfo

	// A nil return value means that the entry was not found. An empty slice
	// means that no provisioning operations are needed.
	GetProvisionedPVCs(pod *v1.Pod, node string) []*v1.PersistentVolumeClaim

	// GetDecisions will return all cached decisions for the given pod.
	GetDecisions(pod *v1.Pod) nodeDecisions

	// DeleteBindings will remove all cached bindings and provisionings for the given pod.
	// TODO: separate the func if it is needed to delete bindings/provisionings individually
	DeleteBindings(pod *v1.Pod)
}

PodBindingCache stores PV binding decisions per pod per node. Pod entries are removed when the Pod is deleted or updated to no longer be schedulable.

func NewPodBindingCache

func NewPodBindingCache() PodBindingCache

NewPodBindingCache creates a pod binding cache.

type SchedulerVolumeBinder

type SchedulerVolumeBinder interface {
	// FindPodVolumes checks if all of a Pod's PVCs can be satisfied by the node.
	//
	// If a PVC is bound, it checks if the PV's NodeAffinity matches the Node.
	// Otherwise, it tries to find an available PV to bind to the PVC.
	//
	// It returns an error when something went wrong or a list of reasons why the node is
	// (currently) not usable for the pod.
	//
	// This function is called by the volume binding scheduler predicate and can be called in parallel
	FindPodVolumes(pod *v1.Pod, node *v1.Node) (reasons ConflictReasons, err error)

	// AssumePodVolumes will:
	// 1. Take the PV matches for unbound PVCs and update the PV cache assuming
	// that the PV is prebound to the PVC.
	// 2. Take the PVCs that need provisioning and update the PVC cache with related
	// annotations set.
	//
	// It returns true if all volumes are fully bound
	//
	// This function will modify assumedPod with the node name.
	// This function is called serially.
	AssumePodVolumes(assumedPod *v1.Pod, nodeName string) (allFullyBound bool, err error)

	// BindPodVolumes will:
	// 1. Initiate the volume binding by making the API call to prebind the PV
	// to its matching PVC.
	// 2. Trigger the volume provisioning by making the API call to set related
	// annotations on the PVC
	// 3. Wait for PVCs to be completely bound by the PV controller
	//
	// This function can be called in parallel.
	BindPodVolumes(assumedPod *v1.Pod) error

	// GetBindingsCache returns the cache used (if any) to store volume binding decisions.
	GetBindingsCache() PodBindingCache

	// DeletePodBindings will delete pod's bindingDecisions in podBindingCache.
	DeletePodBindings(pod *v1.Pod)
}

SchedulerVolumeBinder is used by the scheduler to handle PVC/PV binding and dynamic provisioning. The binding decisions are integrated into the pod scheduling workflow so that the PV NodeAffinity is also considered along with the pod's other scheduling requirements.

This integrates into the existing default scheduler workflow as follows:

  1. The scheduler takes a Pod off the scheduler queue and processes it serially: a. Invokes all predicate functions, parallelized across nodes. FindPodVolumes() is invoked here. b. Invokes all priority functions. Future/TBD c. Selects the best node for the Pod. d. Cache the node selection for the Pod. AssumePodVolumes() is invoked here. i. If PVC binding is required, cache in-memory only: * For manual binding: update PV objects for prebinding to the corresponding PVCs. * For dynamic provisioning: update PVC object with a selected node from c) * For the pod, which PVCs and PVs need API updates. ii. Afterwards, the main scheduler caches the Pod->Node binding in the scheduler's pod cache, This is handled in the scheduler and not here. e. Asynchronously bind volumes and pod in a separate goroutine i. BindPodVolumes() is called first. It makes all the necessary API updates and waits for PV controller to fully bind and provision the PVCs. If binding fails, the Pod is sent back through the scheduler. ii. After BindPodVolumes() is complete, then the scheduler does the final Pod->Node binding.
  2. Once all the assume operations are done in d), the scheduler processes the next Pod in the scheduler queue while the actual binding operation occurs in the background.

func NewVolumeBinder

NewVolumeBinder sets up all the caches needed for the scheduler to make volume binding decisions.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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