framework

package
v1.14.2 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterAction

func RegisterAction(act Action)

RegisterAction register action

func RegisterPluginBuilder

func RegisterPluginBuilder(name string, pc PluginBuilder)

RegisterPluginBuilder register the plugin

Types

type Action

type Action interface {
	// Name returns the unique name of Action.
	Name() string

	// OnActionInit initializes the plugin. It is called once when the framework is created.
	OnActionInit(configurations []conf.Configuration)

	// Initialize initializes the allocator plugins.
	Initialize()

	// Execute allocates resources for the given task.
	Execute(fwk *Framework, schedCtx *agentapi.SchedulingContext)

	// UnInitialize un-initializes the allocator plugins.
	UnInitialize()
}

Action is the interface of agent scheduler action.

func GetAction

func GetAction(name string) (Action, bool)

GetAction get the action by name

type BindContextHandler

type BindContextHandler interface {
	// SetupBindContextExtension allows the plugin to set up extension information in the bind context
	SetupBindContextExtension(state *k8sframework.CycleState, bindCtx *agentapi.BindContext)
}

type Framework

type Framework struct {
	*k8sutil.Framework // Embedding Framework to implement k8sframework.Handle interface

	Plugins        map[string]Plugin
	Actions        []Action
	Tiers          []conf.Tier
	Configurations []conf.Configuration

	// Function registries
	PredicateFns      map[string]api.PredicateFn
	PrePredicateFns   map[string]api.PrePredicateFn
	NodeOrderFns      map[string]api.NodeOrderFn
	BatchNodeOrderFns map[string]api.BatchNodeOrderFn
	NodeMapFns        map[string]api.NodeMapFn
	NodeReduceFns     map[string]api.NodeReduceFn

	// These sets are used to record the names of failed plugins.
	// When there are resource changes, plugins can only focus on the resource changes they are interested in,
	// avoiding unnecessary event wake-ups of unschedulable pods.
	// TODO: Implement QueueingHint and set these failed plugins in queuedPodInfo.
	PrePredicateFailedFns sets.Set[string]
	PredicateFailedFns    sets.Set[string]
	// This lock is mainly used for protecting the above two sets. Because there are concurrent scenarios for Predicates,
	// requiring concurrent updates to Predicate/PrePredicate failed fns
	Mutex sync.RWMutex

	Cache cache.Cache

	// CycleState for the current scheduling cycle
	// Since agent scheduler schedules one pod per cycle, we only need one CycleState.
	// When multiple workers collaborate on scheduling simultaneously in the future,
	// we may need to store cycleState using sync.Map or similar methods.
	CurrentCycleState *k8sframework.CycleState
}

Framework manages the scheduler plugins and their execution points.

func NewFramework

func NewFramework(actions []Action, tiers []conf.Tier, cache cache.Cache, configurations []conf.Configuration) *Framework

NewFramework initializes the framework with the given plugins.

func (*Framework) AddBatchNodeOrderFn

func (f *Framework) AddBatchNodeOrderFn(name string, fn api.BatchNodeOrderFn)

func (*Framework) AddNodeMapFn

func (f *Framework) AddNodeMapFn(name string, fn api.NodeMapFn)

func (*Framework) AddNodeOrderFn

func (f *Framework) AddNodeOrderFn(name string, fn api.NodeOrderFn)

func (*Framework) AddNodeReduceFn

func (f *Framework) AddNodeReduceFn(name string, fn api.NodeReduceFn)

func (*Framework) AddPrePredicateFn

func (f *Framework) AddPrePredicateFn(name string, fn api.PrePredicateFn)

func (*Framework) AddPredicateFn

func (f *Framework) AddPredicateFn(name string, fn api.PredicateFn)

func (*Framework) BatchNodeOrderFn

func (f *Framework) BatchNodeOrderFn(task *api.TaskInfo, nodes []*api.NodeInfo) (map[string]float64, error)

BatchNodeOrderFn invoke node order function of the plugins

func (*Framework) ClearCycleState

func (f *Framework) ClearCycleState()

ClearCycleState clears the current CycleState.

func (*Framework) GetCycleState

func (f *Framework) GetCycleState(taskUID types.UID) *k8sframework.CycleState

GetCycleState returns the CycleState for the current scheduling cycle. Since agent scheduler schedules one pod per cycle, all calls return the same state.

func (*Framework) GetSnapshot

func (f *Framework) GetSnapshot() *k8sutil.Snapshot

GetSnapshot returns the snapshot from the embedded k8sutil.Framework.

func (*Framework) NodeOrderFn

func (f *Framework) NodeOrderFn(task *api.TaskInfo, node *api.NodeInfo) (float64, error)

NodeOrderFn invoke node order function of the plugins

func (*Framework) NodeOrderMapFn

func (f *Framework) NodeOrderMapFn(task *api.TaskInfo, node *api.NodeInfo) (map[string]float64, float64, error)

NodeOrderMapFn invoke node order function of the plugins

func (*Framework) NodeOrderReduceFn

func (f *Framework) NodeOrderReduceFn(task *api.TaskInfo, pluginNodeScoreMap map[string]k8sframework.NodeScoreList) (map[string]float64, error)

NodeOrderReduceFn invoke node order function of the plugins

func (*Framework) OnCycleEnd

func (f *Framework) OnCycleEnd()

OnCycleEnd calls OnCycleEnd for all plugins.

func (*Framework) OnCycleStart

func (f *Framework) OnCycleStart()

OnCycleStart calls OnCycleStart for all plugins.

func (*Framework) PrePredicateFn

func (f *Framework) PrePredicateFn(task *api.TaskInfo) error

PrePredicateFn invoke predicate function of the plugins

func (*Framework) PredicateFn

func (f *Framework) PredicateFn(task *api.TaskInfo, node *api.NodeInfo) error

PredicateFn invoke predicate function of the plugins

func (*Framework) UpdateFailedFns

func (f *Framework) UpdateFailedFns(failedFns sets.Set[string], failedPluginName string)

UpdateFailedFns is used to update the failed plugin sets.

type Plugin

type Plugin interface {
	// Name returns the unique name of Plugin.
	Name() string

	// OnPluginInit initializes the plugin. It is called once when the framework is created.
	OnPluginInit(fwk *Framework)

	// OnCycleStart is called at the beginning of a scheduling cycle.
	OnCycleStart(fwk *Framework)

	// OnCycleEnd is called at the end of a scheduling cycle.
	OnCycleEnd(fwk *Framework)
}

Plugin is the interface of agent scheduler plugin

type PluginBuilder

type PluginBuilder = func(volcanofwk.Arguments) Plugin

PluginBuilder plugin management

func GetPluginBuilder

func GetPluginBuilder(name string) (PluginBuilder, bool)

GetPluginBuilder get the pluginbuilder by name

Jump to

Keyboard shortcuts

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