cache

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2024 License: Apache-2.0 Imports: 68 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultAttachableVolumeQuantity int64 = math.MaxInt32

Functions

func RegisterBindMethod added in v1.5.0

func RegisterBindMethod(binder Binder)

RegisterBindMethod register Bind Method

Types

type BatchBinder added in v1.4.0

type BatchBinder interface {
	Bind(job *api.JobInfo, cluster string) (*api.JobInfo, error)
}

BatchBinder updates podgroup or job information

type Binder

type Binder interface {
	Bind(kubeClient kubernetes.Interface, tasks []*api.TaskInfo) map[api.TaskID]string
}

Binder interface for binding task and hostname

func GetBindMethod added in v1.5.0

func GetBindMethod() Binder

GetBindMethod get the registered Binder

type Cache

type Cache interface {
	// Run start informer
	Run(stopCh <-chan struct{})

	// Snapshot deep copy overall cache information into snapshot
	Snapshot() *api.ClusterInfo

	// WaitForCacheSync waits for all cache synced
	WaitForCacheSync(stopCh <-chan struct{})

	// AddBindTask binds Task to the target host.
	// TODO(jinzhej): clean up expire Tasks.
	AddBindTask(task *api.TaskInfo) error

	// BindPodGroup Pod/PodGroup to cluster
	BindPodGroup(job *api.JobInfo, cluster string) error

	// Evict evicts the task to release resources.
	Evict(task *api.TaskInfo, reason string) error

	// RecordJobStatusEvent records related events according to job status.
	// Deprecated: remove it after removed PDB support.
	RecordJobStatusEvent(job *api.JobInfo, updatePG bool)

	// UpdateJobStatus puts job in backlog for a while.
	UpdateJobStatus(job *api.JobInfo, updatePG bool) (*api.JobInfo, error)

	// UpdateQueueStatus update queue status.
	UpdateQueueStatus(queue *api.QueueInfo) error

	// GetPodVolumes get pod volume on the host
	GetPodVolumes(task *api.TaskInfo, node *v1.Node) (*volumebinding.PodVolumes, error)

	// AllocateVolumes allocates volume on the host to the task
	AllocateVolumes(task *api.TaskInfo, hostname string, podVolumes *volumebinding.PodVolumes) error

	// BindVolumes binds volumes to the task
	BindVolumes(task *api.TaskInfo, volumes *volumebinding.PodVolumes) error

	// RevertVolumes clean cache generated by AllocateVolumes
	RevertVolumes(task *api.TaskInfo, podVolumes *volumebinding.PodVolumes)

	// Client returns the kubernetes clientSet, which can be used by plugins
	Client() kubernetes.Interface

	// ClientConfig returns the rest config
	ClientConfig() *rest.Config

	UpdateSchedulerNumaInfo(sets map[string]api.ResNumaSets) error

	// SharedInformerFactory return scheduler SharedInformerFactory
	SharedInformerFactory() informers.SharedInformerFactory

	// SetMetricsConf set the metrics server related configuration
	SetMetricsConf(conf map[string]string)

	// EventRecorder returns the event recorder
	EventRecorder() record.EventRecorder
}

Cache collects pods/nodes/queues information and provides information snapshot

func New

func New(config *rest.Config, schedulerNames []string, defaultQueue string, nodeSelectors []string, nodeWorkers uint32, ignoredProvisioners []string) Cache

New returns a Cache implementation.

type DefaultBinder added in v1.5.0

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

DefaultBinder with kube client and event recorder

func NewDefaultBinder added in v1.9.0

func NewDefaultBinder(kbclient kubernetes.Interface, record record.EventRecorder) *DefaultBinder

NewDefaultBinder create binder with kube client and event recorder, support fake binder if passed fake client and fake event recorder

func (*DefaultBinder) Bind added in v1.5.0

Bind will send bind request to api server

type Dumper added in v1.8.0

type Dumper struct {
	Cache   Cache
	RootDir string // target directory for the dumped json file
}

Dumper writes some information from the scheduler cache to the scheduler logs for debugging purposes. Usage: run `kill -s USR2 <pid>` in the shell, where <pid> is the process id of the scheduler process.

func (*Dumper) ListenForSignal added in v1.8.0

func (d *Dumper) ListenForSignal(stopCh <-chan struct{})

ListenForSignal starts a goroutine that will respond when process receives SIGUSER1/SIGUSER2 signal.

type Evictor

type Evictor interface {
	Evict(pod *v1.Pod, reason string) error
}

Evictor interface for evict pods

type SchedulerCache

type SchedulerCache struct {
	sync.Mutex

	Binder         Binder
	Evictor        Evictor
	StatusUpdater  StatusUpdater
	PodGroupBinder BatchBinder
	VolumeBinder   VolumeBinder

	Recorder record.EventRecorder

	Jobs            map[schedulingapi.JobID]*schedulingapi.JobInfo
	Nodes           map[string]*schedulingapi.NodeInfo
	Queues          map[schedulingapi.QueueID]*schedulingapi.QueueInfo
	PriorityClasses map[string]*schedulingv1.PriorityClass
	NodeList        []string

	CSINodesStatus map[string]*schedulingapi.CSINodeStatusInfo

	NamespaceCollection map[string]*schedulingapi.NamespaceCollection

	DeletedJobs workqueue.RateLimitingInterface

	BindFlowChannel chan *schedulingapi.TaskInfo

	// IgnoredCSIProvisioners contains a list of provisioners, and pod request pvc with these provisioners will
	// not be counted in pod pvc resource request and node.Allocatable, because the spec.drivers of csinode resource
	// is always null, these provisioners usually are host path csi controllers like rancher.io/local-path and hostpath.csi.k8s.io.
	IgnoredCSIProvisioners sets.Set[string]
	// contains filtered or unexported fields
}

SchedulerCache cache for the kube batch

func NewCustomMockSchedulerCache added in v1.9.0

func NewCustomMockSchedulerCache(schedulerName string,
	binder Binder,
	evictor Evictor,
	statusUpdater StatusUpdater,
	PodGroupBinder BatchBinder,
	volumeBinder VolumeBinder,
	recorder record.EventRecorder,
) *SchedulerCache

NewCustomMockSchedulerCache returns a mock scheduler cache with custom interface

func NewDefaultMockSchedulerCache added in v1.9.0

func NewDefaultMockSchedulerCache(schedulerName string) *SchedulerCache

NewDefaultMockSchedulerCache returns a mock scheduler cache with interface mocked with default fake clients Notes that default events recorder's buffer only has a length 100; when use it do performance test, should use a &FakeRecorder{} without length limit to avoid block

func (*SchedulerCache) AddBindTask added in v1.5.0

func (sc *SchedulerCache) AddBindTask(taskInfo *schedulingapi.TaskInfo) error

AddBindTask add task to be bind to a cache which consumes by go runtime

func (*SchedulerCache) AddJob added in v1.5.0

func (sc *SchedulerCache) AddJob(obj interface{})

AddJob add job to scheduler cache

func (*SchedulerCache) AddNode

func (sc *SchedulerCache) AddNode(obj interface{})

AddNode add node to scheduler cache

func (*SchedulerCache) AddNumaInfoV1alpha1 added in v1.4.0

func (sc *SchedulerCache) AddNumaInfoV1alpha1(obj interface{})

AddNumaInfoV1alpha1 add numa information to scheduler cache

func (*SchedulerCache) AddOrUpdateCSINode added in v1.6.1

func (sc *SchedulerCache) AddOrUpdateCSINode(obj interface{})

func (*SchedulerCache) AddOrUpdateNode added in v1.8.2

func (sc *SchedulerCache) AddOrUpdateNode(node *v1.Node) error

AddOrUpdateNode adds or updates node info in cache.

func (*SchedulerCache) AddPod

func (sc *SchedulerCache) AddPod(obj interface{})

AddPod add pod to scheduler cache

func (*SchedulerCache) AddPodGroupV1beta1 added in v0.4.0

func (sc *SchedulerCache) AddPodGroupV1beta1(obj interface{})

AddPodGroupV1beta1 add podgroup to scheduler cache

func (*SchedulerCache) AddPriorityClass

func (sc *SchedulerCache) AddPriorityClass(obj interface{})

AddPriorityClass add priorityclass to scheduler cache

func (*SchedulerCache) AddQueueV1beta1 added in v0.4.0

func (sc *SchedulerCache) AddQueueV1beta1(obj interface{})

AddQueueV1beta1 add queue to scheduler cache

func (*SchedulerCache) AddResourceQuota

func (sc *SchedulerCache) AddResourceQuota(obj interface{})

AddResourceQuota add ResourceQuota to scheduler cache

func (*SchedulerCache) AllocateVolumes

func (sc *SchedulerCache) AllocateVolumes(task *schedulingapi.TaskInfo, hostname string, podVolumes *volumescheduling.PodVolumes) error

AllocateVolumes allocates volume on the host to the task

func (*SchedulerCache) Bind

func (sc *SchedulerCache) Bind(tasks []*schedulingapi.TaskInfo)

Bind binds task to the target host.

func (*SchedulerCache) BindPodGroup added in v1.4.0

func (sc *SchedulerCache) BindPodGroup(job *schedulingapi.JobInfo, cluster string) error

BindPodGroup binds job to silo cluster

func (*SchedulerCache) BindTask added in v1.5.0

func (sc *SchedulerCache) BindTask()

BindTask do k8s binding with a goroutine

func (*SchedulerCache) BindVolumes

func (sc *SchedulerCache) BindVolumes(task *schedulingapi.TaskInfo, podVolumes *volumescheduling.PodVolumes) error

BindVolumes binds volumes to the task

func (*SchedulerCache) Client added in v1.0.0

func (sc *SchedulerCache) Client() kubernetes.Interface

Client returns the kubernetes clientSet

func (*SchedulerCache) ClientConfig added in v1.6.1

func (sc *SchedulerCache) ClientConfig() *rest.Config

ClientConfig returns the rest config

func (*SchedulerCache) DeleteCSINode added in v1.6.1

func (sc *SchedulerCache) DeleteCSINode(obj interface{})

func (*SchedulerCache) DeleteNode

func (sc *SchedulerCache) DeleteNode(obj interface{})

DeleteNode delete node from scheduler cache

func (*SchedulerCache) DeleteNumaInfoV1alpha1 added in v1.4.0

func (sc *SchedulerCache) DeleteNumaInfoV1alpha1(obj interface{})

DeleteNumaInfoV1alpha1 delete numa information from scheduler cache

func (*SchedulerCache) DeletePod

func (sc *SchedulerCache) DeletePod(obj interface{})

DeletePod delete pod from scheduler cache

func (*SchedulerCache) DeletePodGroupV1beta1 added in v0.4.0

func (sc *SchedulerCache) DeletePodGroupV1beta1(obj interface{})

DeletePodGroupV1beta1 delete podgroup from scheduler cache

func (*SchedulerCache) DeletePriorityClass

func (sc *SchedulerCache) DeletePriorityClass(obj interface{})

DeletePriorityClass delete priorityclass from the scheduler cache

func (*SchedulerCache) DeleteQueueV1beta1 added in v0.4.0

func (sc *SchedulerCache) DeleteQueueV1beta1(obj interface{})

DeleteQueueV1beta1 delete queue from the scheduler cache

func (*SchedulerCache) DeleteResourceQuota

func (sc *SchedulerCache) DeleteResourceQuota(obj interface{})

DeleteResourceQuota delete ResourceQuota from the scheduler cache

func (*SchedulerCache) EventRecorder added in v1.6.0

func (sc *SchedulerCache) EventRecorder() record.EventRecorder

EventRecorder returns the Event Recorder

func (*SchedulerCache) Evict

func (sc *SchedulerCache) Evict(taskInfo *schedulingapi.TaskInfo, reason string) error

Evict will evict the pod.

If error occurs both task and job are guaranteed to be in the original state.

func (*SchedulerCache) GetMetricsData added in v1.6.0

func (sc *SchedulerCache) GetMetricsData()

func (*SchedulerCache) GetPodVolumes added in v1.3.0

func (sc *SchedulerCache) GetPodVolumes(task *schedulingapi.TaskInfo, node *v1.Node) (*volumescheduling.PodVolumes, error)

GetPodVolumes get pod volume on the host

func (*SchedulerCache) NewTaskInfo added in v1.8.2

func (sc *SchedulerCache) NewTaskInfo(pod *v1.Pod) (*schedulingapi.TaskInfo, error)

func (*SchedulerCache) RecordJobStatusEvent

func (sc *SchedulerCache) RecordJobStatusEvent(job *schedulingapi.JobInfo, updatePG bool)

RecordJobStatusEvent records related events according to job status.

func (*SchedulerCache) RemoveNode added in v1.8.2

func (sc *SchedulerCache) RemoveNode(nodeName string) error

RemoveNode removes node info from cache

func (*SchedulerCache) RevertVolumes added in v1.6.0

func (sc *SchedulerCache) RevertVolumes(task *schedulingapi.TaskInfo, podVolumes *volumescheduling.PodVolumes)

RevertVolumes clean cache generated by AllocateVolumes

func (*SchedulerCache) Run

func (sc *SchedulerCache) Run(stopCh <-chan struct{})

Run starts the schedulerCache

func (*SchedulerCache) SetMetricsConf added in v1.6.0

func (sc *SchedulerCache) SetMetricsConf(conf map[string]string)

func (*SchedulerCache) SetSharedInformerFactory added in v1.9.0

func (sc *SchedulerCache) SetSharedInformerFactory(factory informers.SharedInformerFactory)

SetSharedInformerFactory sets the scheduler SharedInformerFactory for unit test

func (*SchedulerCache) SharedInformerFactory added in v1.4.0

func (sc *SchedulerCache) SharedInformerFactory() informers.SharedInformerFactory

SharedInformerFactory returns the scheduler SharedInformerFactory

func (*SchedulerCache) Snapshot

func (sc *SchedulerCache) Snapshot() *schedulingapi.ClusterInfo

Snapshot returns the complete snapshot of the cluster from cache

func (*SchedulerCache) String

func (sc *SchedulerCache) String() string

String returns information about the cache in a string format

func (*SchedulerCache) SyncNode added in v1.8.2

func (sc *SchedulerCache) SyncNode(nodeName string) error

func (*SchedulerCache) UpdateCSINode added in v1.6.1

func (sc *SchedulerCache) UpdateCSINode(oldObj, newObj interface{})

func (*SchedulerCache) UpdateJobStatus

func (sc *SchedulerCache) UpdateJobStatus(job *schedulingapi.JobInfo, updatePG bool) (*schedulingapi.JobInfo, error)

UpdateJobStatus update the status of job and its tasks.

func (*SchedulerCache) UpdateNode

func (sc *SchedulerCache) UpdateNode(oldObj, newObj interface{})

UpdateNode update node to scheduler cache

func (*SchedulerCache) UpdateNumaInfoV1alpha1 added in v1.4.0

func (sc *SchedulerCache) UpdateNumaInfoV1alpha1(oldObj, newObj interface{})

UpdateNumaInfoV1alpha1 update numa information to scheduler cache

func (*SchedulerCache) UpdatePod

func (sc *SchedulerCache) UpdatePod(oldObj, newObj interface{})

UpdatePod update pod to scheduler cache

func (*SchedulerCache) UpdatePodGroupV1beta1 added in v0.4.0

func (sc *SchedulerCache) UpdatePodGroupV1beta1(oldObj, newObj interface{})

UpdatePodGroupV1beta1 add podgroup to scheduler cache

func (*SchedulerCache) UpdatePriorityClass

func (sc *SchedulerCache) UpdatePriorityClass(oldObj, newObj interface{})

UpdatePriorityClass update priorityclass to scheduler cache

func (*SchedulerCache) UpdateQueueStatus added in v1.7.0

func (sc *SchedulerCache) UpdateQueueStatus(queue *schedulingapi.QueueInfo) error

UpdateQueueStatus update the status of queue.

func (*SchedulerCache) UpdateQueueV1beta1 added in v0.4.0

func (sc *SchedulerCache) UpdateQueueV1beta1(oldObj, newObj interface{})

UpdateQueueV1beta1 update queue to scheduler cache

func (*SchedulerCache) UpdateResourceQuota

func (sc *SchedulerCache) UpdateResourceQuota(oldObj, newObj interface{})

UpdateResourceQuota update ResourceQuota to scheduler cache

func (*SchedulerCache) UpdateSchedulerNumaInfo added in v1.4.0

func (sc *SchedulerCache) UpdateSchedulerNumaInfo(AllocatedSets map[string]schedulingapi.ResNumaSets) error

UpdateSchedulerNumaInfo used to update scheduler node cache NumaSchedulerInfo

func (*SchedulerCache) WaitForCacheSync

func (sc *SchedulerCache) WaitForCacheSync(stopCh <-chan struct{})

WaitForCacheSync sync the cache with the api server

type StatusUpdater

type StatusUpdater interface {
	UpdatePodStatus(pod *v1.Pod) (*v1.Pod, error)
	UpdatePodGroup(pg *api.PodGroup) (*api.PodGroup, error)
	UpdateQueueStatus(queue *api.QueueInfo) error
}

StatusUpdater updates pod with given PodCondition

type VolumeBinder

type VolumeBinder interface {
	GetPodVolumes(task *api.TaskInfo, node *v1.Node) (*volumebinding.PodVolumes, error)
	RevertVolumes(task *api.TaskInfo, podVolumes *volumebinding.PodVolumes)
	AllocateVolumes(task *api.TaskInfo, hostname string, podVolumes *volumebinding.PodVolumes) error
	BindVolumes(task *api.TaskInfo, podVolumes *volumebinding.PodVolumes) error
}

VolumeBinder interface for allocate and bind volumes

Jump to

Keyboard shortcuts

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