Documentation
¶
Index ¶
- func RegisterAction(act Action)
- func RegisterPluginBuilder(name string, pc PluginBuilder)
- type Action
- type BindContextHandler
- type Framework
- func (f *Framework) AddBatchNodeOrderFn(name string, fn api.BatchNodeOrderFn)
- func (f *Framework) AddNodeMapFn(name string, fn api.NodeMapFn)
- func (f *Framework) AddNodeOrderFn(name string, fn api.NodeOrderFn)
- func (f *Framework) AddNodeReduceFn(name string, fn api.NodeReduceFn)
- func (f *Framework) AddPrePredicateFn(name string, fn api.PrePredicateFn)
- func (f *Framework) AddPredicateFn(name string, fn api.PredicateFn)
- func (f *Framework) BatchNodeOrderFn(task *api.TaskInfo, nodes []*api.NodeInfo) (map[string]float64, error)
- func (f *Framework) ClearCycleState()
- func (f *Framework) GetCycleState(taskUID types.UID) *k8sframework.CycleState
- func (f *Framework) GetSnapshot() *k8sutil.Snapshot
- func (f *Framework) NodeOrderFn(task *api.TaskInfo, node *api.NodeInfo) (float64, error)
- func (f *Framework) NodeOrderMapFn(task *api.TaskInfo, node *api.NodeInfo) (map[string]float64, float64, error)
- func (f *Framework) NodeOrderReduceFn(task *api.TaskInfo, pluginNodeScoreMap map[string]k8sframework.NodeScoreList) (map[string]float64, error)
- func (f *Framework) OnCycleEnd()
- func (f *Framework) OnCycleStart()
- func (f *Framework) PrePredicateFn(task *api.TaskInfo) error
- func (f *Framework) PredicateFn(task *api.TaskInfo, node *api.NodeInfo) error
- func (f *Framework) UpdateFailedFns(failedFns sets.Set[string], failedPluginName string)
- type Plugin
- type PluginBuilder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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.
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) 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 ¶
GetSnapshot returns the snapshot from the embedded k8sutil.Framework.
func (*Framework) NodeOrderFn ¶
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 ¶
PrePredicateFn invoke predicate function of the plugins
func (*Framework) PredicateFn ¶
PredicateFn invoke predicate function of the plugins
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