framework

package
v0.0.0-...-3bd4b24 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2022 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Evict = iota
	Pipeline
	Allocate
)

Variables

This section is empty.

Functions

func CleanupPluginBuilders

func CleanupPluginBuilders()

func CloseSession

func CloseSession(sess *Session)

CloseSession closes a scheduling session.

func LoadCustomPlugins

func LoadCustomPlugins(pluginsDir string) error

LoadCustomPlugins loads custom scheduling plugins from the given pluginsDir.

func RegisterAction

func RegisterAction(act Action)

func RegisterPluginBuilder

func RegisterPluginBuilder(name string, pb PluginBuilder)

func TimeJitterAfter

func TimeJitterAfter(new, old time.Time, duration, maxJitter time.Duration) bool

TimeJitterAfter returns a new time: old time + duration + jitter time.

Types

type Action

type Action interface {
	Name() string
	Initialize()           // install plugins
	Execute(sess *Session) // execution of the action in the input session
	UnInitialize()         // uninstall plugins
}

Action is the action interface. Typical actions including enqueue, allocate, backfill, etc.

func GetAction

func GetAction(name string) (Action, bool)

type Arguments

type Arguments map[string]interface{}

func GetArgOfActionFromConf

func GetArgOfActionFromConf(configs []conf.Configuration, actionName string) Arguments

GetArgOfActionFromConf returns argument of action reading from configuration of schedule.

func (Arguments) GetBool

func (a Arguments) GetBool(ptr *bool, key string)

func (Arguments) GetFloat64

func (a Arguments) GetFloat64(ptr *float64, key string)

func (Arguments) GetInt

func (a Arguments) GetInt(ptr *int, key string)

type Event

type Event struct {
	Task *apis.TaskInfo
}

Event is happened on tasks

type EventHandler

type EventHandler struct {
	AllocateFunc   func(e *Event)
	DeallocateFunc func(e *Event)
}

type Operation

type Operation int8

type Plugin

type Plugin interface {
	Name() string
	OnSessionOpen(sess *Session)
	OnSessionClose(sess *Session)
}

Plugin is the plugin interface. Custom scheduling algorithms are implemented as plugins.

type PluginBuilder

type PluginBuilder = func(Arguments) Plugin

func GetPluginBuilder

func GetPluginBuilder(name string) (PluginBuilder, bool)

type Session

type Session struct {
	// session ID
	UID types.UID

	TotalResource *apis.Resource

	Jobs           map[apis.JobID]*apis.JobInfo
	Nodes          map[string]*apis.NodeInfo
	RevocableNodes map[string]*apis.NodeInfo
	Queues         map[apis.QueueID]*apis.QueueInfo
	NamespaceInfo  map[apis.NamespaceName]*apis.NamespaceInfo

	// scheduling configs
	Tiers          []conf.Tier
	Configurations []conf.Configuration
	NodeList       []*apis.NodeInfo
	// contains filtered or unexported fields
}

Session defines a scheduling session.

func OpenSession

func OpenSession(cache cache.Cache, tiers []conf.Tier, configs []conf.Configuration) *Session

OpenSession opens a scheduling session and registers plugins and actions according to the input configs.

func (*Session) AddAllocatableFn

func (sess *Session) AddAllocatableFn(name string, fn apis.AllocatableFn)

AddAllocatableFn add allocatable function

func (*Session) AddBatchNodeOrderFn

func (sess *Session) AddBatchNodeOrderFn(name string, fn apis.BatchNodeOrderFn)

AddBatchNodeOrderFn adds Batch Node order function.

func (*Session) AddBestNodeFn

func (sess *Session) AddBestNodeFn(name string, fn apis.BestNodeFn)

AddBestNodeFn add BestNode function.

func (*Session) AddClusterOrderFn

func (sess *Session) AddClusterOrderFn(name string, fn apis.CompareFn)

AddClusterOrderFn adds queue order function.

func (*Session) AddEventHandler

func (sess *Session) AddEventHandler(eh *EventHandler)

AddEventHandler adds event handlers to current session.

func (*Session) AddJobEnqueuableFn

func (sess *Session) AddJobEnqueuableFn(name string, fn apis.VoteFn)

AddJobEnqueuableFn adds job enqueuable function.

func (*Session) AddJobEnqueuedFn

func (sess *Session) AddJobEnqueuedFn(name string, fn apis.JobEnqueuedFn)

AddJobEnqueuedFn adds jobEnqueued function.

func (*Session) AddJobOrderFn

func (sess *Session) AddJobOrderFn(name string, fn apis.CompareFn)

AddJobOrderFn adds job order function.

func (*Session) AddJobPipelinedFn

func (sess *Session) AddJobPipelinedFn(name string, fn apis.VoteFn)

AddJobPipelinedFn adds pipelined function.

func (*Session) AddJobReadyFn

func (sess *Session) AddJobReadyFn(name string, fn apis.ValidateFn)

AddJobReadyFn adds JobReady function.

func (*Session) AddJobStarvingFns

func (sess *Session) AddJobStarvingFns(name string, fn apis.ValidateFn)

AddJobStarvingFns adds jobStarvingFns function.

func (*Session) AddJobValidFn

func (sess *Session) AddJobValidFn(name string, fn apis.ValidateExFn)

AddJobValidFn adds job valid function.

func (*Session) AddNamespaceOrderFn

func (sess *Session) AddNamespaceOrderFn(name string, fn apis.CompareFn)

AddNamespaceOrderFn adds namespace order function.

func (*Session) AddNodeMapFn

func (sess *Session) AddNodeMapFn(name string, fn apis.NodeMapFn)

AddNodeMapFn adds Node map function.

func (*Session) AddNodeOrderFn

func (sess *Session) AddNodeOrderFn(name string, fn apis.NodeOrderFn)

AddNodeOrderFn adds Node order function.

func (*Session) AddNodeReduceFn

func (sess *Session) AddNodeReduceFn(name string, fn apis.NodeReduceFn)

AddNodeReduceFn adds Node reduce function.

func (*Session) AddOverusedFn

func (sess *Session) AddOverusedFn(name string, fn apis.ValidateFn)

AddOverusedFn adds overused function.

func (*Session) AddPredicateFn

func (sess *Session) AddPredicateFn(name string, fn apis.PredicateFn)

AddPredicateFn adds Predicate function.

func (*Session) AddPreemptableFn

func (sess *Session) AddPreemptableFn(name string, fn apis.EvictableFn)

AddPreemptableFn adds preemptable function.

func (*Session) AddQueueOrderFn

func (sess *Session) AddQueueOrderFn(name string, fn apis.CompareFn)

AddQueueOrderFn adds queue order function.

func (*Session) AddReclaimableFn

func (sess *Session) AddReclaimableFn(name string, fn apis.EvictableFn)

AddReclaimableFn adds Reclaimable function.

func (*Session) AddReservedNodesFn

func (sess *Session) AddReservedNodesFn(name string, fn apis.ReservedNodesFn)

AddReservedNodesFn adds reservedNodesFn function.

func (*Session) AddTargetJobFn

func (sess *Session) AddTargetJobFn(name string, fn apis.TargetJobFn)

AddTargetJobFn adds target job function.

func (*Session) AddTaskOrderFn

func (sess *Session) AddTaskOrderFn(name string, fn apis.CompareFn)

AddTaskOrderFn adds task order function.

func (*Session) AddVictimTasksFns

func (sess *Session) AddVictimTasksFns(name string, fn []apis.VictimTasksFn)

AddVictimTasksFns adds victimTasksFns function.

func (*Session) Allocatable

func (sess *Session) Allocatable(queue *apis.QueueInfo, candidate *apis.TaskInfo) bool

Allocatable invoke allocatable function of the plugins

func (*Session) Allocate

func (sess *Session) Allocate(task *apis.TaskInfo, nodeInfo *apis.NodeInfo) error

func (*Session) BatchNodeOrderFn

func (sess *Session) BatchNodeOrderFn(task *apis.TaskInfo, nodes []*apis.NodeInfo) (map[string]float64, error)

BatchNodeOrderFn invokes batch nodes order function of the plugins.

func (*Session) BestNodeFn

func (sess *Session) BestNodeFn(task *apis.TaskInfo, nodeScores map[float64][]*apis.NodeInfo) *apis.NodeInfo

BestNodeFn invokes bestNode function of the plugins.

func (*Session) BindPodGroup

func (sess *Session) BindPodGroup(job *apis.JobInfo, cluster string) error

BindPodGroup binds PodGroup to the specified cluster.

func (*Session) ClusterOrderFn

func (sess *Session) ClusterOrderFn(l, r interface{}) bool

ClusterOrderFn invokes ClusterOrderFn function of the plugins.

func (*Session) Evict

func (sess *Session) Evict(reclaimee *apis.TaskInfo, reason string) error

func (Session) InformerFactory

func (sess Session) InformerFactory() informers.SharedInformerFactory

InformerFactory returns the session's ShareInformerFactory.

func (*Session) JobEnqueuable

func (sess *Session) JobEnqueuable(obj interface{}) bool

JobEnqueuable invokes jobEnqueuableFns function of the plugins.

func (*Session) JobEnqueued

func (sess *Session) JobEnqueued(obj interface{})

JobEnqueued invokes jobEnqueuedFns function of the plugins.

func (*Session) JobOrderFn

func (sess *Session) JobOrderFn(l, r interface{}) bool

JobOrderFn invokes job order function of the plugins.

func (*Session) JobPipelined

func (sess *Session) JobPipelined(obj interface{}) bool

JobPipelined invoke pipelined function of the plugins. Check if job has get enough resource to run, it returns true if at least one plugin votes permit.

func (*Session) JobReady

func (sess *Session) JobReady(obj interface{}) bool

JobReady invoke job ready function of the plugins, and it returns true is the input obj is judged as ready by all plugins in sess.

func (*Session) JobStarving

func (sess *Session) JobStarving(obj interface{}) bool

JobStarving invoke jobStarving function of the plugins. Check if job still need more resource.

func (*Session) JobValid

func (sess *Session) JobValid(obj interface{}) *apis.ValidateResult

JobValid invokes job valid function of the plugins.

func (Session) KubeClient

func (sess Session) KubeClient() kubernetes.Interface

KubeClient returns the kubernetes client.

func (*Session) NamespaceOrderFn

func (sess *Session) NamespaceOrderFn(l, r interface{}) bool

NamespaceOrderFn invokes namespace order function of the plugins.

func (*Session) NodeOrderFn

func (sess *Session) NodeOrderFn(task *apis.TaskInfo, node *apis.NodeInfo) (float64, error)

NodeOrderFn invokes node order function of the plugins.

func (*Session) NodeOrderMapFn

func (sess *Session) NodeOrderMapFn(task *apis.TaskInfo, node *apis.NodeInfo) (map[string]float64, float64, error)

NodeOrderMapFn invokes node order function of the plugins.

func (*Session) NodeOrderReduceFn

func (sess *Session) NodeOrderReduceFn(task *apis.TaskInfo, pluginNodeScoreMap map[string]k8sframework.NodeScoreList) (map[string]float64, error)

NodeOrderReduceFn invokes node order reduce function of the plugins.

func (*Session) Overused

func (sess *Session) Overused(queue *apis.QueueInfo) bool

Overused invokes the overused function of the plugins, and returns true if the input queue is judged as overused by any plugin in sess.

func (*Session) Pipeline

func (sess *Session) Pipeline(task *apis.TaskInfo, hostname string) error

func (*Session) PredicateFn

func (sess *Session) PredicateFn(task *apis.TaskInfo, node *apis.NodeInfo) error

PredicateFn invokes predicate function of the plugins.

func (*Session) Preemptable

func (sess *Session) Preemptable(preemptor *apis.TaskInfo, preemptees []*apis.TaskInfo) []*apis.TaskInfo

Preemptable invokes the preemptable func of the plugins and returns the preemptable tasks.

func (*Session) QueueOrderFn

func (sess *Session) QueueOrderFn(l, r interface{}) bool

QueueOrderFn invokes queue order function of the plugins.

func (*Session) Reclaimable

func (sess *Session) Reclaimable(reclaimer *apis.TaskInfo, reclaimees []*apis.TaskInfo) []*apis.TaskInfo

Reclaimable invokes the reclaimable func of the plugins and returns the reclaimed tasks.

func (Session) RecordPodGroupEvent

func (sess Session) RecordPodGroupEvent(podGroup *apis.PodGroup, eventType, reason, msg string)

RecordPodGroupEvent records podGroup events.

func (*Session) ReservedNodes

func (sess *Session) ReservedNodes()

ReservedNodes invokes reserve node function of the plugins.

func (*Session) Statement

func (sess *Session) Statement() *Statement

Statement constructs a Statement instance with sess.

func (Session) String

func (sess Session) String() string

String returns nodes and jobs information in the session.

func (*Session) TargetJob

func (sess *Session) TargetJob(jobs []*apis.JobInfo) *apis.JobInfo

TargetJob invokes targetJobFns function of the plugins. It returns the target job from the job list.

func (*Session) TaskCompareFns

func (sess *Session) TaskCompareFns(l, r interface{}) int

TaskCompareFns invokes task order function of the plugins.

func (*Session) TaskOrderFn

func (sess *Session) TaskOrderFn(l, r interface{}) bool

TaskOrderFn invokes task order function of the plugins.

func (*Session) UpdatePodGroupCondition

func (sess *Session) UpdatePodGroupCondition(jobInfo *apis.JobInfo, cond *scheduling.PodGroupCondition) error

UpdatePodGroupCondition updates job condition accordingly.

func (*Session) UpdateSchedulerNumaInfo

func (sess *Session) UpdateSchedulerNumaInfo(AllocatedSets map[string]apis.ResNumaSets)

UpdateSchedulerNumaInfo updates SchedulerNumaInfo.

func (*Session) VictimTasks

func (sess *Session) VictimTasks(tasks []*apis.TaskInfo) map[*apis.TaskInfo]bool

VictimTasks invokes ReservedNodes function of the plugins.

type Statement

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

Statement defines a series of operation in a scheduling session.

func NewStatement

func NewStatement(sess *Session) *Statement

func (*Statement) Allocate

func (s *Statement) Allocate(task *apis.TaskInfo, nodeInfo *apis.NodeInfo) error

Allocate will allocate task to node. Specifically, it will update s.sess.Jobs and s.sess.Nodes status info and add this operation to s.operations.

func (*Statement) Commit

func (s *Statement) Commit()

Commit executes all operations in s in turn.

func (*Statement) Discard

func (s *Statement) Discard()

Discard discards all operations in s in a reversed order.

func (*Statement) Evict

func (s *Statement) Evict(reclaimee *apis.TaskInfo, reason string) error

Evict will evict reclaimee for reason. Specifically, it will update s.sess.Jobs and s.sess.Nodes status info and add this operation to s.operations.

func (*Statement) Pipeline

func (s *Statement) Pipeline(task *apis.TaskInfo, hostname string) error

Pipeline will pipeline task to host. Specifically, it will update s.sess.Jobs and s.sess.Nodes status info and add this operation to s.operations.

Directories

Path Synopsis
Package mock_framework is a generated GoMock package.
Package mock_framework is a generated GoMock package.

Jump to

Keyboard shortcuts

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