v1alpha1

package
v1.16.15 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxNodeScore is the maximum score a Score plugin is expected to return.
	MaxNodeScore int = schedulerapi.MaxPriority

	// MinNodeScore is the minimum score a Score plugin is expected to return.
	MinNodeScore int = 0
)
View Source
const (
	// NotFound is the not found error message.
	NotFound = "not found"
)

Variables

This section is empty.

Functions

func DecodeInto added in v1.16.0

func DecodeInto(configuration *runtime.Unknown, into interface{}) error

DecodeInto decodes configuration whose type is *runtime.Unknown to the interface into.

Types

type BindPlugin added in v1.16.0

type BindPlugin interface {
	Plugin
	// Bind plugins will not be called until all pre-bind plugins have completed. Each
	// bind plugin is called in the configured order. A bind plugin may choose whether
	// or not to handle the given Pod. If a bind plugin chooses to handle a Pod, the
	// remaining bind plugins are skipped. When a bind plugin does not handle a pod,
	// it must return Skip in its Status code. If a bind plugin returns an Error, the
	// pod is rejected and will not be bound.
	Bind(pc *PluginContext, p *v1.Pod, nodeName string) *Status
}

BindPlugin is an interface that must be implemented by "bind" plugins. Bind plugins are used to bind a pod to a Node.

type Code

type Code int

Code is the Status code/type which is returned from plugins.

const (
	// Success means that plugin ran correctly and found pod schedulable.
	// NOTE: A nil status is also considered as "Success".
	Success Code = iota
	// Error is used for internal plugin errors, unexpected input, etc.
	Error
	// Unschedulable is used when a plugin finds a pod unschedulable. The scheduler might attempt to
	// preempt other pods to get this pod scheduled. Use UnschedulableAndUnresolvable to make the
	// scheduler skip preemption.
	// The accompanying status message should explain why the pod is unschedulable.
	Unschedulable
	// UnschedulableAndUnresolvable is used when a (pre-)filter plugin finds a pod unschedulable and
	// preemption would not change anything. Plugins should return Unschedulable if it is possible
	// that the pod can get scheduled with preemption.
	// The accompanying status message should explain why the pod is unschedulable.
	UnschedulableAndUnresolvable
	// Wait is used when a permit plugin finds a pod scheduling should wait.
	Wait
	// Skip is used when a bind plugin chooses to skip binding.
	Skip
)

These are predefined codes used in a Status.

type ContextData

type ContextData interface{}

ContextData is a generic type for arbitrary data stored in PluginContext.

type ContextKey

type ContextKey string

ContextKey is the type of keys stored in PluginContext.

type FilterPlugin added in v1.16.0

type FilterPlugin interface {
	Plugin
	// Filter is called by the scheduling framework.
	// All FilterPlugins should return "Success" to declare that
	// the given node fits the pod. If Filter doesn't return "Success",
	// please refer scheduler/algorithm/predicates/error.go
	// to set error message.
	Filter(pc *PluginContext, pod *v1.Pod, nodeName string) *Status
}

FilterPlugin is an interface for Filter plugins. These plugins are called at the filter extension point for filtering out hosts that cannot run a pod. This concept used to be called 'predicate' in the original scheduler. These plugins should return "Success", "Unschedulable" or "Error" in Status.code. However, the scheduler accepts other valid codes as well. Anything other than "Success" will lead to exclusion of the given host from running the pod.

type Framework

type Framework interface {
	FrameworkHandle
	// QueueSortFunc returns the function to sort pods in scheduling queue
	QueueSortFunc() LessFunc

	// RunPreFilterPlugins runs the set of configured prefilter plugins. It returns
	// *Status and its code is set to non-success if any of the plugins returns
	// anything but Success. If a non-success status is returned, then the scheduling
	// cycle is aborted.
	RunPreFilterPlugins(pc *PluginContext, pod *v1.Pod) *Status

	// RunFilterPlugins runs the set of configured filter plugins for pod on the
	// given host. If any of these plugins returns any status other than "Success",
	// the given node is not suitable for running the pod.
	RunFilterPlugins(pc *PluginContext, pod *v1.Pod, nodeName string) *Status

	// RunPostFilterPlugins runs the set of configured post-filter plugins. If any
	// of these plugins returns any status other than "Success", the given node is
	// rejected. The filteredNodeStatuses is the set of filtered nodes and their statuses.
	RunPostFilterPlugins(pc *PluginContext, pod *v1.Pod, nodes []*v1.Node, filteredNodesStatuses NodeToStatusMap) *Status

	// RunScorePlugins runs the set of configured scoring plugins. It returns a map that
	// stores for each scoring plugin name the corresponding NodeScoreList(s).
	// It also returns *Status, which is set to non-success if any of the plugins returns
	// a non-success status.
	RunScorePlugins(pc *PluginContext, pod *v1.Pod, nodes []*v1.Node) (PluginToNodeScores, *Status)

	// RunPreBindPlugins runs the set of configured prebind plugins. It returns
	// *Status and its code is set to non-success if any of the plugins returns
	// anything but Success. If the Status code is "Unschedulable", it is
	// considered as a scheduling check failure, otherwise, it is considered as an
	// internal error. In either case the pod is not going to be bound.
	RunPreBindPlugins(pc *PluginContext, pod *v1.Pod, nodeName string) *Status

	// RunPostBindPlugins runs the set of configured postbind plugins.
	RunPostBindPlugins(pc *PluginContext, pod *v1.Pod, nodeName string)

	// RunReservePlugins runs the set of configured reserve plugins. If any of these
	// plugins returns an error, it does not continue running the remaining ones and
	// returns the error. In such case, pod will not be scheduled.
	RunReservePlugins(pc *PluginContext, pod *v1.Pod, nodeName string) *Status

	// RunUnreservePlugins runs the set of configured unreserve plugins.
	RunUnreservePlugins(pc *PluginContext, pod *v1.Pod, nodeName string)

	// RunPermitPlugins runs the set of configured permit plugins. If any of these
	// plugins returns a status other than "Success" or "Wait", it does not continue
	// running the remaining plugins and returns an error. Otherwise, if any of the
	// plugins returns "Wait", then this function will block for the timeout period
	// returned by the plugin, if the time expires, then it will return an error.
	// Note that if multiple plugins asked to wait, then we wait for the minimum
	// timeout duration.
	RunPermitPlugins(pc *PluginContext, pod *v1.Pod, nodeName string) *Status

	// RunBindPlugins runs the set of configured bind plugins. A bind plugin may choose
	// whether or not to handle the given Pod. If a bind plugin chooses to skip the
	// binding, it should return code=4("skip") status. Otherwise, it should return "Error"
	// or "Success". If none of the plugins handled binding, RunBindPlugins returns
	// code=4("skip") status.
	RunBindPlugins(pc *PluginContext, pod *v1.Pod, nodeName string) *Status
}

Framework manages the set of plugins in use by the scheduling framework. Configured plugins are called at specified points in a scheduling context.

func NewFramework

func NewFramework(r Registry, plugins *config.Plugins, args []config.PluginConfig) (Framework, error)

NewFramework initializes plugins given the configuration and the registry.

type FrameworkHandle

type FrameworkHandle interface {
	// NodeInfoSnapshot return the latest NodeInfo snapshot. The snapshot
	// is taken at the beginning of a scheduling cycle and remains unchanged until
	// a pod finishes "Reserve" point. There is no guarantee that the information
	// remains unchanged in the binding phase of scheduling, so plugins in the binding
	// cycle(permit/pre-bind/bind/post-bind/un-reserve plugin) should not use it,
	// otherwise a concurrent read/write error might occur, they should use scheduler
	// cache instead.
	NodeInfoSnapshot() *schedulernodeinfo.Snapshot

	// IterateOverWaitingPods acquires a read lock and iterates over the WaitingPods map.
	IterateOverWaitingPods(callback func(WaitingPod))

	// GetWaitingPod returns a waiting pod given its UID.
	GetWaitingPod(uid types.UID) WaitingPod
}

FrameworkHandle provides data and some tools that plugins can use. It is passed to the plugin factories at the time of plugin initialization. Plugins must store and use this handle to call framework functions.

type LessFunc

type LessFunc func(podInfo1, podInfo2 *PodInfo) bool

LessFunc is the function to sort pod info

type NodeScore added in v1.16.0

type NodeScore struct {
	Name  string
	Score int
}

NodeScore is a struct with node name and score.

type NodeScoreList added in v1.16.0

type NodeScoreList []NodeScore

NodeScoreList declares a list of nodes and their scores.

type NodeToStatusMap added in v1.16.0

type NodeToStatusMap map[string]*Status

NodeToStatusMap declares map from node name to its status.

type PermitPlugin

type PermitPlugin interface {
	Plugin
	// Permit is called before binding a pod (and before prebind plugins). Permit
	// plugins are used to prevent or delay the binding of a Pod. A permit plugin
	// must return success or wait with timeout duration, or the pod will be rejected.
	// The pod will also be rejected if the wait timeout or the pod is rejected while
	// waiting. Note that if the plugin returns "wait", the framework will wait only
	// after running the remaining plugins given that no other plugin rejects the pod.
	Permit(pc *PluginContext, p *v1.Pod, nodeName string) (*Status, time.Duration)
}

PermitPlugin is an interface that must be implemented by "permit" plugins. These plugins are called before a pod is bound to a node.

type Plugin

type Plugin interface {
	Name() string
}

Plugin is the parent type for all the scheduling framework plugins.

type PluginContext

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

PluginContext provides a mechanism for plugins to store and retrieve arbitrary data. ContextData stored by one plugin can be read, altered, or deleted by another plugin. PluginContext does not provide any data protection, as all plugins are assumed to be trusted.

func NewPluginContext

func NewPluginContext() *PluginContext

NewPluginContext initializes a new PluginContext and returns its pointer.

func (*PluginContext) Delete

func (c *PluginContext) Delete(key ContextKey)

Delete deletes data with the given key from PluginContext. This function is not thread safe. In multi-threaded code, lock should be acquired first.

func (*PluginContext) Lock

func (c *PluginContext) Lock()

Lock acquires PluginContext lock.

func (*PluginContext) RLock

func (c *PluginContext) RLock()

RLock acquires PluginContext read lock.

func (*PluginContext) RUnlock

func (c *PluginContext) RUnlock()

RUnlock releases PluginContext read lock.

func (*PluginContext) Read

func (c *PluginContext) Read(key ContextKey) (ContextData, error)

Read retrieves data with the given "key" from PluginContext. If the key is not present an error is returned. This function is not thread safe. In multi-threaded code, lock should be acquired first.

func (*PluginContext) Unlock

func (c *PluginContext) Unlock()

Unlock releases PluginContext lock.

func (*PluginContext) Write

func (c *PluginContext) Write(key ContextKey, val ContextData)

Write stores the given "val" in PluginContext with the given "key". This function is not thread safe. In multi-threaded code, lock should be acquired first.

type PluginFactory

type PluginFactory = func(configuration *runtime.Unknown, f FrameworkHandle) (Plugin, error)

PluginFactory is a function that builds a plugin.

type PluginToNodeScores added in v1.16.0

type PluginToNodeScores map[string]NodeScoreList

PluginToNodeScores declares a map from plugin name to its NodeScoreList.

type PodInfo

type PodInfo struct {
	Pod *v1.Pod
	// The time pod added to the scheduling queue.
	Timestamp time.Time
}

PodInfo is minimum cell in the scheduling queue.

type PostBindPlugin added in v1.16.0

type PostBindPlugin interface {
	Plugin
	// PostBind is called after a pod is successfully bound. These plugins are
	// informational. A common application of this extension point is for cleaning
	// up. If a plugin needs to clean-up its state after a pod is scheduled and
	// bound, PostBind is the extension point that it should register.
	PostBind(pc *PluginContext, p *v1.Pod, nodeName string)
}

PostBindPlugin is an interface that must be implemented by "postbind" plugins. These plugins are called after a pod is successfully bound to a node.

type PostFilterPlugin added in v1.16.0

type PostFilterPlugin interface {
	Plugin
	// PostFilter is called by the scheduling framework after a list of nodes
	// passed the filtering phase. All postfilter plugins must return success or
	// the pod will be rejected. The filteredNodesStatuses is the set of filtered nodes
	// and their filter status.
	PostFilter(pc *PluginContext, pod *v1.Pod, nodes []*v1.Node, filteredNodesStatuses NodeToStatusMap) *Status
}

PostFilterPlugin is an interface for Post-filter plugin. Post-filter is an informational extension point. Plugins will be called with a list of nodes that passed the filtering phase. A plugin may use this data to update internal state or to generate logs/metrics.

type PreBindPlugin added in v1.16.0

type PreBindPlugin interface {
	Plugin
	// PreBind is called before binding a pod. All prebind plugins must return
	// success or the pod will be rejected and won't be sent for binding.
	PreBind(pc *PluginContext, p *v1.Pod, nodeName string) *Status
}

PreBindPlugin is an interface that must be implemented by "prebind" plugins. These plugins are called before a pod being scheduled.

type PreFilterPlugin added in v1.16.0

type PreFilterPlugin interface {
	Plugin
	// PreFilter is called at the beginning of the scheduling cycle. All PreFilter
	// plugins must return success or the pod will be rejected.
	PreFilter(pc *PluginContext, p *v1.Pod) *Status
}

PreFilterPlugin is an interface that must be implemented by "prefilter" plugins. These plugins are called at the beginning of the scheduling cycle.

type QueueSortPlugin

type QueueSortPlugin interface {
	Plugin
	// Less are used to sort pods in the scheduling queue.
	Less(*PodInfo, *PodInfo) bool
}

QueueSortPlugin is an interface that must be implemented by "QueueSort" plugins. These plugins are used to sort pods in the scheduling queue. Only one queue sort plugin may be enabled at a time.

type Registry

type Registry map[string]PluginFactory

Registry is a collection of all available plugins. The framework uses a registry to enable and initialize configured plugins. All plugins must be in the registry before initializing the framework.

func NewRegistry

func NewRegistry() Registry

NewRegistry builds a default registry with all the default plugins. This is the registry that Kubernetes default scheduler uses. A scheduler that runs custom plugins, can pass a different Registry and when initializing the scheduler.

func (Registry) Register

func (r Registry) Register(name string, factory PluginFactory) error

Register adds a new plugin to the registry. If a plugin with the same name exists, it returns an error.

func (Registry) Unregister

func (r Registry) Unregister(name string) error

Unregister removes an existing plugin from the registry. If no plugin with the provided name exists, it returns an error.

type ReservePlugin

type ReservePlugin interface {
	Plugin
	// Reserve is called by the scheduling framework when the scheduler cache is
	// updated.
	Reserve(pc *PluginContext, p *v1.Pod, nodeName string) *Status
}

ReservePlugin is an interface for Reserve plugins. These plugins are called at the reservation point. These are meant to update the state of the plugin. This concept used to be called 'assume' in the original scheduler. These plugins should return only Success or Error in Status.code. However, the scheduler accepts other valid codes as well. Anything other than Success will lead to rejection of the pod.

type ScorePlugin added in v1.16.0

type ScorePlugin interface {
	Plugin
	// Score is called on each filtered node. It must return success and an integer
	// indicating the rank of the node. All scoring plugins must return success or
	// the pod will be rejected.
	Score(pc *PluginContext, p *v1.Pod, nodeName string) (int, *Status)
}

ScorePlugin is an interface that must be implemented by "score" plugins to rank nodes that passed the filtering phase.

type ScoreWithNormalizePlugin added in v1.16.0

type ScoreWithNormalizePlugin interface {
	ScorePlugin
	// NormalizeScore is called for all node scores produced by the same plugin's "Score"
	// method. A successful run of NormalizeScore will update the scores list and return
	// a success status.
	NormalizeScore(pc *PluginContext, p *v1.Pod, scores NodeScoreList) *Status
}

ScoreWithNormalizePlugin is an interface that must be implemented by "score" plugins that also need to normalize the node scoring results produced by the same plugin's "Score" method.

type Status

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

Status indicates the result of running a plugin. It consists of a code and a message. When the status code is not `Success`, the status message should explain why. NOTE: A nil Status is also considered as Success.

func NewStatus

func NewStatus(code Code, msg string) *Status

NewStatus makes a Status out of the given arguments and returns its pointer.

func (*Status) AsError

func (s *Status) AsError() error

AsError returns an "error" object with the same message as that of the Status.

func (*Status) Code

func (s *Status) Code() Code

Code returns code of the Status.

func (*Status) IsSuccess

func (s *Status) IsSuccess() bool

IsSuccess returns true if and only if "Status" is nil or Code is "Success".

func (*Status) IsUnschedulable added in v1.16.0

func (s *Status) IsUnschedulable() bool

IsUnschedulable returns true if "Status" is Unschedulable (Unschedulable or UnschedulableAndUnresolvable).

func (*Status) Message

func (s *Status) Message() string

Message returns message of the Status.

type UnreservePlugin

type UnreservePlugin interface {
	Plugin
	// Unreserve is called by the scheduling framework when a reserved pod was
	// rejected in a later phase.
	Unreserve(pc *PluginContext, p *v1.Pod, nodeName string)
}

UnreservePlugin is an interface for Unreserve plugins. This is an informational extension point. If a pod was reserved and then rejected in a later phase, then un-reserve plugins will be notified. Un-reserve plugins should clean up state associated with the reserved Pod.

type WaitingPod

type WaitingPod interface {
	// GetPod returns a reference to the waiting pod.
	GetPod() *v1.Pod
	// Allow the waiting pod to be scheduled. Returns true if the allow signal was
	// successfully delivered, false otherwise.
	Allow() bool
	// Reject declares the waiting pod unschedulable. Returns true if the allow signal
	// was successfully delivered, false otherwise.
	Reject(msg string) bool
}

WaitingPod represents a pod currently waiting in the permit phase.

Jump to

Keyboard shortcuts

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