core

package
v0.0.0-...-6a1eb3e Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: Apache-2.0 Imports: 21 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTaskResourceInfos

func GetTaskResourceInfos(trMgr *TaskResourceManager) *sync.Map

GetTaskResourceInfos returns task resource infos.

func GetTaskResourceName

func GetTaskResourceName(pod *corev1.Pod) (string, bool)

GetTaskResourceName get task resource name from pod annotations.

func GetTaskResourceUID

func GetTaskResourceUID(pod *corev1.Pod) (string, bool)

GetTaskResourceUID get task resource uid from pod labels.

func GetWaitTimeDuration

func GetWaitTimeDuration(tr *kusciaapisv1alpha1.TaskResource, resourceReservedSeconds *time.Duration) time.Duration

GetWaitTimeDuration returns a wait timeout based on the following precedences: 1. spec.resourceReservedSeconds of the given task resource, if specified 2. given resourceReservedSeconds, if not nil 3. fall back to defaultWaitTime

Types

type Manager

type Manager interface {
	PreFilter(context.Context, *corev1.Pod) error
	Reserve(context.Context, *corev1.Pod)
	Unreserve(context.Context, *kusciaapisv1alpha1.TaskResource, *corev1.Pod)
	Permit(context.Context, *corev1.Pod) Status
	PreBind(context.Context, *corev1.Pod) (framework.Code, error)
	DeletePermittedTaskResource(*kusciaapisv1alpha1.TaskResource)
	CalculateAssignedPods(*kusciaapisv1alpha1.TaskResource, *corev1.Pod) int
	ActivateSiblings(*corev1.Pod, *framework.CycleState)
	GetTaskResource(*corev1.Pod) (string, *kusciaapisv1alpha1.TaskResource, bool)
}

Manager defines the interfaces for TaskResource management.

type Status

type Status string
const (
	// TaskResourceNotSpecified denotes no TaskResource is specified in the Pod spec.
	TaskResourceNotSpecified Status = "TaskResource not specified"
	// TaskResourceNotFound denotes the specified TaskResource in the Pod spec is not found in API server.
	TaskResourceNotFound Status = "TaskResource not found"
	Success              Status = "Success"
	Wait                 Status = "Wait"
)

type TaskResourceManager

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

TaskResourceManager defines the scheduling operation called.

func NewTaskResourceManager

func NewTaskResourceManager(kusciaClient kusciaclientset.Interface,
	snapshotSharedLister framework.SharedLister,
	trInformer kusciainformer.TaskResourceInformer,
	podInformer kubeinformer.PodInformer,
	nsInformer kubeinformer.NamespaceInformer,
	timeout *time.Duration) *TaskResourceManager

NewTaskResourceManager creates a new operation object.

func (*TaskResourceManager) ActivateSiblings

func (trMgr *TaskResourceManager) ActivateSiblings(pod *corev1.Pod, state *framework.CycleState)

ActivateSiblings stashes the pods belonging to the same TaskResource of the given pod in the given state, with a reserved key "kubernetes.io/pods-to-activate".

func (*TaskResourceManager) CalculateAssignedPods

func (trMgr *TaskResourceManager) CalculateAssignedPods(tr *kusciaapisv1alpha1.TaskResource, pod *corev1.Pod) int

CalculateAssignedPods returns the number of pods that has been assigned nodes: assumed or bound.

func (*TaskResourceManager) DeletePermittedTaskResource

func (trMgr *TaskResourceManager) DeletePermittedTaskResource(tr *kusciaapisv1alpha1.TaskResource)

DeletePermittedTaskResource deletes a TaskResource that passes Pre-Filter but reaches PostFilter.

func (*TaskResourceManager) GetTaskResource

func (trMgr *TaskResourceManager) GetTaskResource(pod *corev1.Pod) (string, *kusciaapisv1alpha1.TaskResource, bool)

GetTaskResource returns the task resource that a Pod belongs to in cache.

func (*TaskResourceManager) Permit

func (trMgr *TaskResourceManager) Permit(ctx context.Context, pod *corev1.Pod) Status

Permit permits a pod to run, if the minReservedPods match, it would send a signal to chan.

func (*TaskResourceManager) PreBind

func (trMgr *TaskResourceManager) PreBind(ctx context.Context, pod *corev1.Pod) (framework.Code, error)

PreBind is used to pre-check.

func (*TaskResourceManager) PreFilter

func (trMgr *TaskResourceManager) PreFilter(ctx context.Context, pod *corev1.Pod) error

PreFilter filters out a pod if 1. it belongs to a TaskResource that was recently denied or 2. the total number of pods in the TaskResource is less than the minimum number of pods that is required to be scheduled.

func (*TaskResourceManager) Reserve

func (trMgr *TaskResourceManager) Reserve(ctx context.Context, pod *corev1.Pod)

Reserve records task resource info of pod.

func (*TaskResourceManager) Unreserve

func (trMgr *TaskResourceManager) Unreserve(ctx context.Context, tr *kusciaapisv1alpha1.TaskResource, pod *corev1.Pod)

Unreserve is used to patch task resource status related to pod.

Jump to

Keyboard shortcuts

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