frameworkext

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2023 License: Apache-2.0 Imports: 51 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxReservationScore is the maximum score a ReservationScorePlugin plugin is expected to return.
	MaxReservationScore int64 = 100

	// MinReservationScore is the minimum score a ReservationScorePlugin plugin is expected to return.
	MinReservationScore int64 = 0
)

Variables

View Source
var AssignedPodDelete = framework.ClusterEvent{Resource: framework.Pod, ActionType: framework.Delete, Label: "AssignedPodDelete"}

Functions

func AddFlags added in v0.7.0

func AddFlags(fs *pflag.FlagSet)

func DebugFiltersSetter added in v1.1.0

func DebugFiltersSetter(val string) (string, error)

DebugFiltersSetter updates debugFilterFailure to specified value

func DebugScoresSetter added in v0.7.0

func DebugScoresSetter(val string) (string, error)

DebugScoresSetter updates debugTopNScores to specified value

func PluginFactoryProxy

func PluginFactoryProxy(extenderFactory *FrameworkExtenderFactory, factoryFn frameworkruntime.PluginFactory) frameworkruntime.PluginFactory

PluginFactoryProxy is used to proxy the call to the PluginFactory function and pass in the ExtendedHandle for the custom plugin

func SetNominatedReservation added in v1.2.0

func SetNominatedReservation(cycleState *framework.CycleState, reservationInfos map[string]*ReservationInfo)

func SetupCustomInformers added in v1.3.0

func SetupCustomInformers(informerFactory informers.SharedInformerFactory)

Types

type Controller added in v1.0.0

type Controller interface {
	Start()
	Name() string
}

type ControllerProvider added in v1.0.0

type ControllerProvider interface {
	NewControllers() ([]Controller, error)
}

type ControllersMap added in v1.0.0

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

func NewControllersMap added in v1.0.0

func NewControllersMap() *ControllersMap

func (*ControllersMap) RegisterControllers added in v1.0.0

func (cm *ControllersMap) RegisterControllers(plugin framework.Plugin)

func (*ControllersMap) Start added in v1.0.0

func (cm *ControllersMap) Start()

type ErrorHandler added in v1.3.0

type ErrorHandler func(*framework.QueuedPodInfo, error) bool

type ExtendedHandle

type ExtendedHandle interface {
	framework.Handle
	// Scheduler return the scheduler adapter to support operating with cache and schedulingQueue.
	// NOTE: Plugins do not acquire a dispatcher instance during plugin initialization,
	// nor are they allowed to hold the object within the plugin object.
	Scheduler() Scheduler
	KoordinatorClientSet() koordinatorclientset.Interface
	KoordinatorSharedInformerFactory() koordinatorinformers.SharedInformerFactory
	RegisterErrorHandler(handler ErrorHandler)
	RegisterForgetPodHandler(handler ForgetPodHandler)
	ForgetPod(pod *corev1.Pod) error
}

ExtendedHandle extends the k8s scheduling framework Handle interface to facilitate plugins to access Koordinator's resources and states.

type FakeQueue added in v1.3.0

type FakeQueue struct {
	Pods                map[string]*corev1.Pod
	UnschedulablePods   map[string]*corev1.Pod
	AssignedPods        map[string]*corev1.Pod
	AssignedUpdatedPods map[string]*corev1.Pod
}

func (*FakeQueue) Add added in v1.3.0

func (f *FakeQueue) Add(pod *corev1.Pod) error

func (*FakeQueue) AddUnschedulableIfNotPresent added in v1.3.0

func (f *FakeQueue) AddUnschedulableIfNotPresent(pod *framework.QueuedPodInfo, podSchedulingCycle int64) error

func (*FakeQueue) AssignedPodAdded added in v1.3.0

func (f *FakeQueue) AssignedPodAdded(pod *corev1.Pod)

func (*FakeQueue) AssignedPodUpdated added in v1.3.0

func (f *FakeQueue) AssignedPodUpdated(pod *corev1.Pod)

func (*FakeQueue) Delete added in v1.3.0

func (f *FakeQueue) Delete(pod *corev1.Pod) error

func (*FakeQueue) MoveAllToActiveOrBackoffQueue added in v1.3.0

func (f *FakeQueue) MoveAllToActiveOrBackoffQueue(event framework.ClusterEvent)

func (*FakeQueue) SchedulingCycle added in v1.3.0

func (f *FakeQueue) SchedulingCycle() int64

func (*FakeQueue) Update added in v1.3.0

func (f *FakeQueue) Update(oldPod, newPod *corev1.Pod) error

type FakeScheduler added in v1.3.0

type FakeScheduler struct {
	Pods       map[string]*corev1.Pod
	AssumedPod map[string]*corev1.Pod
	Queue      *FakeQueue
}

func NewFakeScheduler added in v1.3.0

func NewFakeScheduler() *FakeScheduler

func (*FakeScheduler) AddPod added in v1.3.0

func (f *FakeScheduler) AddPod(pod *corev1.Pod) error

func (*FakeScheduler) AssumePod added in v1.3.0

func (f *FakeScheduler) AssumePod(pod *corev1.Pod) error

func (*FakeScheduler) ForgetPod added in v1.3.0

func (f *FakeScheduler) ForgetPod(pod *corev1.Pod) error

func (*FakeScheduler) GetCache added in v1.3.0

func (f *FakeScheduler) GetCache() SchedulerCache

func (*FakeScheduler) GetPod added in v1.3.0

func (f *FakeScheduler) GetPod(pod *corev1.Pod) (*corev1.Pod, error)

func (*FakeScheduler) GetSchedulingQueue added in v1.3.0

func (f *FakeScheduler) GetSchedulingQueue() SchedulingQueue

func (*FakeScheduler) InvalidNodeInfo added in v1.3.0

func (f *FakeScheduler) InvalidNodeInfo(nodeName string) error

func (*FakeScheduler) IsAssumedPod added in v1.3.0

func (f *FakeScheduler) IsAssumedPod(pod *corev1.Pod) (bool, error)

func (*FakeScheduler) RemovePod added in v1.3.0

func (f *FakeScheduler) RemovePod(pod *corev1.Pod) error

func (*FakeScheduler) UpdatePod added in v1.3.0

func (f *FakeScheduler) UpdatePod(oldPod, newPod *corev1.Pod) error

type FilterTransformer added in v1.2.0

type FilterTransformer interface {
	SchedulingTransformer
	BeforeFilter(ctx context.Context, cycleState *framework.CycleState, pod *corev1.Pod, nodeInfo *framework.NodeInfo) (*corev1.Pod, *framework.NodeInfo, bool, *framework.Status)
}

FilterTransformer is executed before Filter.

type ForgetPodHandler added in v1.3.0

type ForgetPodHandler func(pod *corev1.Pod)

type FrameworkExtender added in v0.6.0

type FrameworkExtender interface {
	framework.Framework
	ExtendedHandle

	SetConfiguredPlugins(plugins *schedconfig.Plugins)

	RunReservationExtensionPreRestoreReservation(ctx context.Context, cycleState *framework.CycleState, pod *corev1.Pod) *framework.Status
	RunReservationExtensionRestoreReservation(ctx context.Context, cycleState *framework.CycleState, podToSchedule *corev1.Pod, matched []*ReservationInfo, unmatched []*ReservationInfo, nodeInfo *framework.NodeInfo) (PluginToReservationRestoreStates, *framework.Status)
	RunReservationExtensionFinalRestoreReservation(ctx context.Context, cycleState *framework.CycleState, pod *corev1.Pod, states PluginToNodeReservationRestoreStates) *framework.Status

	RunReservationFilterPlugins(ctx context.Context, cycleState *framework.CycleState, pod *corev1.Pod, reservationInfo *ReservationInfo, nodeName string) *framework.Status
	RunReservationScorePlugins(ctx context.Context, cycleState *framework.CycleState, pod *corev1.Pod, reservationInfos []*ReservationInfo, nodeName string) (PluginToReservationScores, *framework.Status)
}

FrameworkExtender extends the K8s Scheduling Framework interface to provide more extension methods to support Koordinator.

func NewFrameworkExtender added in v1.2.0

type FrameworkExtenderFactory added in v0.6.0

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

func NewFrameworkExtenderFactory added in v0.6.0

func NewFrameworkExtenderFactory(options ...Option) (*FrameworkExtenderFactory, error)

func (FrameworkExtenderFactory) Error added in v1.3.0

func (d FrameworkExtenderFactory) Error(podInfo *framework.QueuedPodInfo, err error)

func (*FrameworkExtenderFactory) GetExtender added in v1.2.0

func (f *FrameworkExtenderFactory) GetExtender(profileName string) FrameworkExtender

func (*FrameworkExtenderFactory) InitScheduler added in v1.3.0

func (f *FrameworkExtenderFactory) InitScheduler(sched Scheduler)

func (*FrameworkExtenderFactory) InterceptSchedulerError added in v1.3.0

func (f *FrameworkExtenderFactory) InterceptSchedulerError(sched *scheduler.Scheduler)

func (*FrameworkExtenderFactory) KoordinatorClientSet added in v1.2.0

func (f *FrameworkExtenderFactory) KoordinatorClientSet() koordinatorclientset.Interface

func (*FrameworkExtenderFactory) KoordinatorSharedInformerFactory added in v1.2.0

func (f *FrameworkExtenderFactory) KoordinatorSharedInformerFactory() koordinatorinformers.SharedInformerFactory

func (*FrameworkExtenderFactory) NewFrameworkExtender added in v1.2.0

func (f *FrameworkExtenderFactory) NewFrameworkExtender(fw framework.Framework) FrameworkExtender

func (FrameworkExtenderFactory) RegisterErrorHandler added in v1.3.0

func (d FrameworkExtenderFactory) RegisterErrorHandler(handler ErrorHandler)

func (*FrameworkExtenderFactory) Run added in v1.2.0

func (f *FrameworkExtenderFactory) Run()

func (*FrameworkExtenderFactory) Scheduler added in v1.3.0

func (f *FrameworkExtenderFactory) Scheduler() Scheduler

Scheduler return the scheduler adapter to support operating with cache and schedulingQueue. NOTE: Plugins do not acquire a dispatcher instance during plugin initialization, nor are they allowed to hold the object within the plugin object.

type NodeReservationRestoreStates added in v1.3.0

type NodeReservationRestoreStates map[string]interface{}

NodeReservationRestoreStates declares a map from plugin name to its ReservationRestoreState.

type Option added in v0.5.0

type Option func(*extendedHandleOptions)

func WithKoordinatorClientSet added in v0.5.0

func WithKoordinatorClientSet(koordinatorClientSet koordinatorclientset.Interface) Option

func WithKoordinatorSharedInformerFactory added in v0.5.0

func WithKoordinatorSharedInformerFactory(informerFactory koordinatorinformers.SharedInformerFactory) Option

func WithServicesEngine added in v0.7.0

func WithServicesEngine(engine *services.Engine) Option

type PluginToNodeReservationRestoreStates added in v1.3.0

type PluginToNodeReservationRestoreStates map[string]NodeReservationRestoreStates

PluginToNodeReservationRestoreStates declares a map from plugin name to its NodeReservationRestoreStates.

type PluginToReservationRestoreStates added in v1.3.0

type PluginToReservationRestoreStates map[string]interface{}

PluginToReservationRestoreStates declares a map from plugin name to its ReservationRestoreState.

type PluginToReservationScores added in v1.2.0

type PluginToReservationScores map[string]ReservationScoreList

PluginToReservationScores declares a map from plugin name to its ReservationScoreList.

type PodRequirement added in v1.3.0

type PodRequirement struct {
	Namespace string
	Name      string
	UID       types.UID
	Requests  corev1.ResourceList
	Ports     framework.HostPortInfo
}

func NewPodRequirement added in v1.3.0

func NewPodRequirement(pod *corev1.Pod) *PodRequirement

func (*PodRequirement) Clone added in v1.3.0

func (p *PodRequirement) Clone() *PodRequirement

type PreBindExtensions added in v1.3.0

type PreBindExtensions interface {
	framework.Plugin
	ApplyPatch(ctx context.Context, cycleState *framework.CycleState, originalObj, modifiedObj metav1.Object) *framework.Status
}

PreBindExtensions is an extension to PreBind, which supports converting multiple modifications to the same object into a Patch operation. It supports configuring multiple plugin instances. A certain instance can be skipped if it does not need to be processed. Once a plugin instance returns success or failure, the process ends.

type PreFilterTransformer added in v1.2.0

type PreFilterTransformer interface {
	SchedulingTransformer
	// BeforePreFilter If there is a change to the incoming Pod, it needs to be modified after DeepCopy and returned.
	BeforePreFilter(ctx context.Context, cycleState *framework.CycleState, pod *corev1.Pod) (*corev1.Pod, bool, *framework.Status)
	// AfterPreFilter is executed after PreFilter.
	// There is a chance to trigger the correction of the State data of each plugin after the PreFilter.
	AfterPreFilter(ctx context.Context, cycleState *framework.CycleState, pod *corev1.Pod) *framework.Status
}

PreFilterTransformer is executed before and after PreFilter.

type ReservationFilterPlugin added in v1.2.0

type ReservationFilterPlugin interface {
	framework.Plugin
	FilterReservation(ctx context.Context, cycleState *framework.CycleState, pod *corev1.Pod, reservationInfo *ReservationInfo, nodeName string) *framework.Status
}

ReservationFilterPlugin is an interface for Filter Reservation plugins. These plugins will be called during the Reserve phase to determine whether the Reservation can participate in the Reserve

type ReservationInfo added in v1.3.0

type ReservationInfo struct {
	Reservation      *schedulingv1alpha1.Reservation
	Pod              *corev1.Pod
	ResourceNames    []corev1.ResourceName
	Allocatable      corev1.ResourceList
	Allocated        corev1.ResourceList
	AllocatablePorts framework.HostPortInfo
	AllocatedPorts   framework.HostPortInfo
	AssignedPods     map[types.UID]*PodRequirement
}

func GetNominatedReservation added in v1.2.0

func GetNominatedReservation(cycleState *framework.CycleState, nodeName string) *ReservationInfo

func NewReservationInfo added in v1.3.0

func NewReservationInfo(r *schedulingv1alpha1.Reservation) *ReservationInfo

func NewReservationInfoFromPod added in v1.3.0

func NewReservationInfoFromPod(pod *corev1.Pod) *ReservationInfo

func (*ReservationInfo) AddAssignedPod added in v1.3.0

func (ri *ReservationInfo) AddAssignedPod(pod *corev1.Pod)

func (*ReservationInfo) Clone added in v1.3.0

func (ri *ReservationInfo) Clone() *ReservationInfo

func (*ReservationInfo) GetAllocatePolicy added in v1.3.0

func (*ReservationInfo) GetName added in v1.3.0

func (ri *ReservationInfo) GetName() string

func (*ReservationInfo) GetNamespace added in v1.3.0

func (ri *ReservationInfo) GetNamespace() string

func (*ReservationInfo) GetNodeName added in v1.3.0

func (ri *ReservationInfo) GetNodeName() string

func (*ReservationInfo) GetObject added in v1.3.0

func (ri *ReservationInfo) GetObject() metav1.Object

func (*ReservationInfo) GetPodOwners added in v1.3.0

func (*ReservationInfo) GetPriority added in v1.3.0

func (ri *ReservationInfo) GetPriority() int32

func (*ReservationInfo) GetReservePod added in v1.3.0

func (ri *ReservationInfo) GetReservePod() *corev1.Pod

func (*ReservationInfo) IsAllocateOnce added in v1.3.0

func (ri *ReservationInfo) IsAllocateOnce() bool

func (*ReservationInfo) IsAvailable added in v1.3.0

func (ri *ReservationInfo) IsAvailable() bool

func (*ReservationInfo) IsTerminating added in v1.3.0

func (ri *ReservationInfo) IsTerminating() bool

func (*ReservationInfo) IsUnschedulable added in v1.3.0

func (ri *ReservationInfo) IsUnschedulable() bool

func (*ReservationInfo) RemoveAssignedPod added in v1.3.0

func (ri *ReservationInfo) RemoveAssignedPod(pod *corev1.Pod)

func (*ReservationInfo) UID added in v1.3.0

func (ri *ReservationInfo) UID() types.UID

func (*ReservationInfo) UpdatePod added in v1.3.0

func (ri *ReservationInfo) UpdatePod(pod *corev1.Pod)

func (*ReservationInfo) UpdateReservation added in v1.3.0

func (ri *ReservationInfo) UpdateReservation(r *schedulingv1alpha1.Reservation)

type ReservationNominator added in v1.2.0

type ReservationNominator interface {
	framework.Plugin
	NominateReservation(ctx context.Context, cycleState *framework.CycleState, pod *corev1.Pod, nodeName string) (*ReservationInfo, *framework.Status)
}

ReservationNominator nominates a more suitable Reservation in the Reserve stage and Pod will bind this Reservation. The Reservation will be recorded in CycleState through SetNominatedReservation. When executing Reserve, each plugin will obtain the currently used Reservation through GetNominatedReservation, and locate the previously returned reusable resources for Pod allocation.

type ReservationPreBindPlugin added in v1.2.0

type ReservationPreBindPlugin interface {
	framework.Plugin
	PreBindReservation(ctx context.Context, cycleState *framework.CycleState, reservation *schedulingv1alpha1.Reservation, nodeName string) *framework.Status
}

ReservationPreBindPlugin performs special binding logic specifically for Reservation in the PreBind phase. Similar to the built-in VolumeBinding plugin of kube-scheduler, it does not support Reservation, and how Reservation itself uses PVC reserved resources also needs special handling. In addition, implementing this interface can clearly indicate that the plugin supports Reservation.

type ReservationRestorePlugin added in v1.3.0

type ReservationRestorePlugin interface {
	framework.Plugin
	PreRestoreReservation(ctx context.Context, cycleState *framework.CycleState, pod *corev1.Pod) *framework.Status
	RestoreReservation(ctx context.Context, cycleState *framework.CycleState, podToSchedule *corev1.Pod, matched []*ReservationInfo, unmatched []*ReservationInfo, nodeInfo *framework.NodeInfo) (interface{}, *framework.Status)
	FinalRestoreReservation(ctx context.Context, cycleState *framework.CycleState, pod *corev1.Pod, states NodeReservationRestoreStates) *framework.Status
}

ReservationRestorePlugin is used to support the return of fine-grained resources held by Reservation, such as CPU Cores, GPU Devices, etc. During Pod scheduling, resources held by these reservations need to be allocated first, otherwise resources will be wasted.

type ReservationScore added in v1.2.0

type ReservationScore struct {
	Name      string
	Namespace string
	UID       types.UID
	Score     int64
}

ReservationScore is a struct with reservation name and score.

type ReservationScoreList added in v1.2.0

type ReservationScoreList []ReservationScore

ReservationScoreList declares a list of reservations and their scores.

type ReservationScorePlugin added in v1.2.0

type ReservationScorePlugin interface {
	framework.Plugin
	ScoreReservation(ctx context.Context, cycleState *framework.CycleState, pod *corev1.Pod, reservationInfo *ReservationInfo, nodeName string) (int64, *framework.Status)
}

ReservationScorePlugin is an interface that must be implemented by "ScoreReservation" plugins to rank reservations that passed the reserve phase.

type Scheduler added in v1.3.0

type Scheduler interface {
	GetCache() SchedulerCache
	GetSchedulingQueue() SchedulingQueue
}

Scheduler exports scheduler internal cache and queue interface for testability.

type SchedulerAdapter added in v1.3.0

type SchedulerAdapter struct {
	Scheduler *scheduler.Scheduler
}

func (*SchedulerAdapter) GetCache added in v1.3.0

func (s *SchedulerAdapter) GetCache() SchedulerCache

func (*SchedulerAdapter) GetSchedulingQueue added in v1.3.0

func (s *SchedulerAdapter) GetSchedulingQueue() SchedulingQueue

func (*SchedulerAdapter) MoveAllToActiveOrBackoffQueue added in v1.3.0

func (s *SchedulerAdapter) MoveAllToActiveOrBackoffQueue(event framework.ClusterEvent)

type SchedulerCache added in v1.3.0

type SchedulerCache interface {
	AddPod(pod *corev1.Pod) error
	UpdatePod(oldPod, newPod *corev1.Pod) error
	RemovePod(pod *corev1.Pod) error
	AssumePod(pod *corev1.Pod) error
	IsAssumedPod(pod *corev1.Pod) (bool, error)
	GetPod(pod *corev1.Pod) (*corev1.Pod, error)
	ForgetPod(pod *corev1.Pod) error
	InvalidNodeInfo(nodeName string) error
}

type SchedulingQueue added in v1.3.0

type SchedulingQueue interface {
	Add(pod *corev1.Pod) error
	Update(oldPod, newPod *corev1.Pod) error
	Delete(pod *corev1.Pod) error
	AddUnschedulableIfNotPresent(pod *framework.QueuedPodInfo, podSchedulingCycle int64) error
	SchedulingCycle() int64
	AssignedPodAdded(pod *corev1.Pod)
	AssignedPodUpdated(pod *corev1.Pod)
	MoveAllToActiveOrBackoffQueue(event framework.ClusterEvent)
}

type SchedulingTransformer added in v1.2.0

type SchedulingTransformer interface {
	Name() string
}

SchedulingTransformer is the parent type for all the custom transformer plugins.

type ScoreTransformer added in v1.2.0

type ScoreTransformer interface {
	SchedulingTransformer
	BeforeScore(ctx context.Context, cycleState *framework.CycleState, pod *corev1.Pod, nodes []*corev1.Node) (*corev1.Pod, []*corev1.Node, bool, *framework.Status)
}

ScoreTransformer is executed before Score.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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