v1alpha1

package
v1.19.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: May 5, 2020 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

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

	// MinNodeScore is the minimum score a Score plugin is expected to return.
	MinNodeScore int64 = 0

	// MaxTotalScore is the maximum total score.
	MaxTotalScore int64 = math.MaxInt64
)
View Source
const DefaultBindAllHostIP = "0.0.0.0"

DefaultBindAllHostIP defines the default ip address used to bind to all host.

View Source
const (
	// Filter is the name of the filter extension point.
	Filter = "Filter"
)
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(obj runtime.Object, into interface{}) error

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

func GetPodKey added in v1.19.0

func GetPodKey(pod *v1.Pod) (string, error)

GetPodKey returns the string key of a pod.

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(ctx context.Context, state *CycleState, 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.

func (Code) String added in v1.17.0

func (c Code) String() string

type CycleState added in v1.17.0

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

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

func NewCycleState added in v1.17.0

func NewCycleState() *CycleState

NewCycleState initializes a new CycleState and returns its pointer.

func (*CycleState) Clone added in v1.17.0

func (c *CycleState) Clone() *CycleState

Clone creates a copy of CycleState and returns its pointer. Clone returns nil if the context being cloned is nil.

func (*CycleState) Delete added in v1.17.0

func (c *CycleState) Delete(key StateKey)

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

func (*CycleState) Lock added in v1.17.0

func (c *CycleState) Lock()

Lock acquires CycleState lock.

func (*CycleState) RLock added in v1.17.0

func (c *CycleState) RLock()

RLock acquires CycleState read lock.

func (*CycleState) RUnlock added in v1.17.0

func (c *CycleState) RUnlock()

RUnlock releases CycleState read lock.

func (*CycleState) Read added in v1.17.0

func (c *CycleState) Read(key StateKey) (StateData, error)

Read retrieves data with the given "key" from CycleState. 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 (*CycleState) SetRecordPluginMetrics added in v1.18.0

func (c *CycleState) SetRecordPluginMetrics(flag bool)

SetRecordPluginMetrics sets recordPluginMetrics to the given value.

func (*CycleState) ShouldRecordPluginMetrics added in v1.18.0

func (c *CycleState) ShouldRecordPluginMetrics() bool

ShouldRecordPluginMetrics returns whether PluginExecutionDuration metrics should be recorded.

func (*CycleState) Unlock added in v1.17.0

func (c *CycleState) Unlock()

Unlock releases CycleState lock.

func (*CycleState) Write added in v1.17.0

func (c *CycleState) Write(key StateKey, val StateData)

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

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.
	// For the node being evaluated, Filter plugins should look at the passed
	// nodeInfo reference for this particular node's information (e.g., pods
	// considered to be running on the node) instead of looking it up in the
	// NodeInfoSnapshot because we don't guarantee that they will be the same.
	// For example, during preemption, we may pass a copy of the original
	// nodeInfo object that has some pods removed from it to evaluate the
	// possibility of preempting them to schedule the target pod.
	Filter(ctx context.Context, state *CycleState, pod *v1.Pod, nodeInfo *NodeInfo) *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(ctx context.Context, state *CycleState, pod *v1.Pod) *Status

	// RunFilterPlugins runs the set of configured filter plugins for pod on
	// the given node. Note that for the node being evaluated, the passed nodeInfo
	// reference could be different from the one in NodeInfoSnapshot map (e.g., pods
	// considered to be running on the node could be different). For example, during
	// preemption, we may pass a copy of the original nodeInfo object that has some pods
	// removed from it to evaluate the possibility of preempting them to
	// schedule the target pod.
	RunFilterPlugins(ctx context.Context, state *CycleState, pod *v1.Pod, nodeInfo *NodeInfo) PluginToStatus

	// RunPreFilterExtensionAddPod calls the AddPod interface for the set of configured
	// PreFilter plugins. It returns directly if any of the plugins return any
	// status other than Success.
	RunPreFilterExtensionAddPod(ctx context.Context, state *CycleState, podToSchedule *v1.Pod, podToAdd *v1.Pod, nodeInfo *NodeInfo) *Status

	// RunPreFilterExtensionRemovePod calls the RemovePod interface for the set of configured
	// PreFilter plugins. It returns directly if any of the plugins return any
	// status other than Success.
	RunPreFilterExtensionRemovePod(ctx context.Context, state *CycleState, podToSchedule *v1.Pod, podToAdd *v1.Pod, nodeInfo *NodeInfo) *Status

	// RunPreScorePlugins runs the set of configured pre-score plugins. If any
	// of these plugins returns any status other than "Success", the given pod is rejected.
	RunPreScorePlugins(ctx context.Context, state *CycleState, pod *v1.Pod, nodes []*v1.Node) *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(ctx context.Context, state *CycleState, 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(ctx context.Context, state *CycleState, pod *v1.Pod, nodeName string) *Status

	// RunPostBindPlugins runs the set of configured postbind plugins.
	RunPostBindPlugins(ctx context.Context, state *CycleState, 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(ctx context.Context, state *CycleState, pod *v1.Pod, nodeName string) *Status

	// RunUnreservePlugins runs the set of configured unreserve plugins.
	RunUnreservePlugins(ctx context.Context, state *CycleState, 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 create and add waiting pod
	// to a map of currently waiting pods and return status with "Wait" code.
	// Pod will remain waiting pod for the minimum duration returned by the permit plugins.
	RunPermitPlugins(ctx context.Context, state *CycleState, pod *v1.Pod, nodeName string) *Status

	// WaitOnPermit will block, if the pod is a waiting pod, until the waiting pod is rejected or allowed.
	WaitOnPermit(ctx context.Context, pod *v1.Pod) *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=5("skip") status. Otherwise, it should return "Error"
	// or "Success". If none of the plugins handled binding, RunBindPlugins returns
	// code=5("skip") status.
	RunBindPlugins(ctx context.Context, state *CycleState, pod *v1.Pod, nodeName string) *Status

	// HasFilterPlugins returns true if at least one filter plugin is defined.
	HasFilterPlugins() bool

	// HasScorePlugins returns true if at least one score plugin is defined.
	HasScorePlugins() bool

	// ListPlugins returns a map of extension point name to list of configured Plugins.
	ListPlugins() map[string][]config.Plugin
}

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, opts ...Option) (Framework, error)

NewFramework initializes plugins given the configuration and the registry.

type FrameworkHandle

type FrameworkHandle interface {
	// SnapshotSharedLister returns listers from the latest NodeInfo Snapshot. The snapshot
	// is taken at the beginning of a scheduling cycle and remains unchanged until
	// a pod finishes "Permit" point. There is no guarantee that the information
	// remains unchanged in the binding phase of scheduling, so plugins in the binding
	// cycle (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.
	SnapshotSharedLister() SharedLister

	// 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

	// RejectWaitingPod rejects a waiting pod given its UID.
	RejectWaitingPod(uid types.UID)

	// ClientSet returns a kubernetes clientSet.
	ClientSet() clientset.Interface

	SharedInformerFactory() informers.SharedInformerFactory

	// VolumeBinder returns the volume binder used by scheduler.
	VolumeBinder() scheduling.SchedulerVolumeBinder
}

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 HostPortInfo added in v1.19.0

type HostPortInfo map[string]map[ProtocolPort]struct{}

HostPortInfo stores mapping from ip to a set of ProtocolPort

func (HostPortInfo) Add added in v1.19.0

func (h HostPortInfo) Add(ip, protocol string, port int32)

Add adds (ip, protocol, port) to HostPortInfo

func (HostPortInfo) CheckConflict added in v1.19.0

func (h HostPortInfo) CheckConflict(ip, protocol string, port int32) bool

CheckConflict checks if the input (ip, protocol, port) conflicts with the existing ones in HostPortInfo.

func (HostPortInfo) Len added in v1.19.0

func (h HostPortInfo) Len() int

Len returns the total number of (ip, protocol, port) tuple in HostPortInfo

func (HostPortInfo) Remove added in v1.19.0

func (h HostPortInfo) Remove(ip, protocol string, port int32)

Remove removes (ip, protocol, port) from HostPortInfo

type ImageStateSummary added in v1.19.0

type ImageStateSummary struct {
	// Size of the image
	Size int64
	// Used to track how many nodes have this image
	NumNodes int
}

ImageStateSummary provides summarized information about the state of an image.

type LessFunc

type LessFunc func(podInfo1, podInfo2 *QueuedPodInfo) bool

LessFunc is the function to sort pod info

type NodeInfo added in v1.19.0

type NodeInfo struct {

	// Pods running on the node.
	Pods []*PodInfo

	// The subset of pods with affinity.
	PodsWithAffinity []*PodInfo

	// Ports allocated on the node.
	UsedPorts HostPortInfo

	// Total requested resources of all pods on this node. This includes assumed
	// pods, which scheduler has sent for binding, but may not be scheduled yet.
	Requested *Resource
	// Total requested resources of all pods on this node with a minimum value
	// applied to each container's CPU and memory requests. This does not reflect
	// the actual resource requests for this node, but is used to avoid scheduling
	// many zero-request pods onto one node.
	NonZeroRequested *Resource
	// We store allocatedResources (which is Node.Status.Allocatable.*) explicitly
	// as int64, to avoid conversions and accessing map.
	Allocatable *Resource

	// ImageStates holds the entry of an image if and only if this image is on the node. The entry can be used for
	// checking an image's existence and advanced usage (e.g., image locality scheduling policy) based on the image
	// state information.
	ImageStates map[string]*ImageStateSummary

	// TransientInfo holds the information pertaining to a scheduling cycle. This will be destructed at the end of
	// scheduling cycle.
	// TODO: @ravig. Remove this once we have a clear approach for message passing across predicates and priorities.
	TransientInfo *TransientSchedulerInfo

	// Whenever NodeInfo changes, generation is bumped.
	// This is used to avoid cloning it if the object didn't change.
	Generation int64
	// contains filtered or unexported fields
}

NodeInfo is node level aggregated information.

func NewNodeInfo added in v1.19.0

func NewNodeInfo(pods ...*v1.Pod) *NodeInfo

NewNodeInfo returns a ready to use empty NodeInfo object. If any pods are given in arguments, their information will be aggregated in the returned object.

func (*NodeInfo) AddPod added in v1.19.0

func (n *NodeInfo) AddPod(pod *v1.Pod)

AddPod adds pod information to this NodeInfo.

func (*NodeInfo) Clone added in v1.19.0

func (n *NodeInfo) Clone() *NodeInfo

Clone returns a copy of this node.

func (*NodeInfo) FilterOutPods added in v1.19.0

func (n *NodeInfo) FilterOutPods(pods []*v1.Pod) []*v1.Pod

FilterOutPods receives a list of pods and filters out those whose node names are equal to the node of this NodeInfo, but are not found in the pods of this NodeInfo.

Preemption logic simulates removal of pods on a node by removing them from the corresponding NodeInfo. In order for the simulation to work, we call this method on the pods returned from SchedulerCache, so that predicate functions see only the pods that are not removed from the NodeInfo.

func (*NodeInfo) Node added in v1.19.0

func (n *NodeInfo) Node() *v1.Node

Node returns overall information about this node.

func (*NodeInfo) RemovePod added in v1.19.0

func (n *NodeInfo) RemovePod(pod *v1.Pod) error

RemovePod subtracts pod information from this NodeInfo.

func (*NodeInfo) SetNode added in v1.19.0

func (n *NodeInfo) SetNode(node *v1.Node) error

SetNode sets the overall node information.

func (*NodeInfo) String added in v1.19.0

func (n *NodeInfo) String() string

String returns representation of human readable format of this NodeInfo.

type NodeInfoLister added in v1.19.0

type NodeInfoLister interface {
	// Returns the list of NodeInfos.
	List() ([]*NodeInfo, error)
	// Returns the list of NodeInfos of nodes with pods with affinity terms.
	HavePodsWithAffinityList() ([]*NodeInfo, error)
	// Returns the NodeInfo of the given node name.
	Get(nodeName string) (*NodeInfo, error)
}

NodeInfoLister interface represents anything that can list/get NodeInfo objects from node name.

type NodeScore added in v1.16.0

type NodeScore struct {
	Name  string
	Score int64
}

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 Option added in v1.17.0

type Option func(*frameworkOptions)

Option for the framework.

func WithClientSet added in v1.17.0

func WithClientSet(clientSet clientset.Interface) Option

WithClientSet sets clientSet for the scheduling framework.

func WithInformerFactory added in v1.17.0

func WithInformerFactory(informerFactory informers.SharedInformerFactory) Option

WithInformerFactory sets informer factory for the scheduling framework.

func WithRunAllFilters added in v1.18.0

func WithRunAllFilters(runAllFilters bool) Option

WithRunAllFilters sets the runAllFilters flag, which means RunFilterPlugins accumulates all failure Statuses.

func WithSnapshotSharedLister added in v1.17.0

func WithSnapshotSharedLister(snapshotSharedLister SharedLister) Option

WithSnapshotSharedLister sets the SharedLister of the snapshot.

func WithVolumeBinder added in v1.18.0

func WithVolumeBinder(binder scheduling.SchedulerVolumeBinder) Option

WithVolumeBinder sets volume binder for the scheduling framework.

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(ctx context.Context, state *CycleState, 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 PluginFactory

type PluginFactory = func(configuration runtime.Object, 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 PluginToStatus added in v1.18.0

type PluginToStatus map[string]*Status

PluginToStatus maps plugin name to status. Currently used to identify which Filter plugin returned which status.

func (PluginToStatus) Merge added in v1.18.0

func (p PluginToStatus) Merge() *Status

Merge merges the statuses in the map into one. The resulting status code have the following precedence: Error, UnschedulableAndUnresolvable, Unschedulable.

type PodInfo

type PodInfo struct {
	Pod *v1.Pod
}

PodInfo is a wrapper to a Pod with additional pre-computed information to accelerate processing. This information is typically immutable (e.g., pre-processed inter-pod affinity selectors).

func NewPodInfo added in v1.19.0

func NewPodInfo(pod *v1.Pod) *PodInfo

NewPodInfo return a new PodInfo

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(ctx context.Context, state *CycleState, 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 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(ctx context.Context, state *CycleState, 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 PreFilterExtensions added in v1.17.0

type PreFilterExtensions interface {
	// AddPod is called by the framework while trying to evaluate the impact
	// of adding podToAdd to the node while scheduling podToSchedule.
	AddPod(ctx context.Context, state *CycleState, podToSchedule *v1.Pod, podToAdd *v1.Pod, nodeInfo *NodeInfo) *Status
	// RemovePod is called by the framework while trying to evaluate the impact
	// of removing podToRemove from the node while scheduling podToSchedule.
	RemovePod(ctx context.Context, state *CycleState, podToSchedule *v1.Pod, podToRemove *v1.Pod, nodeInfo *NodeInfo) *Status
}

PreFilterExtensions is an interface that is included in plugins that allow specifying callbacks to make incremental updates to its supposedly pre-calculated state.

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(ctx context.Context, state *CycleState, p *v1.Pod) *Status
	// PreFilterExtensions returns a PreFilterExtensions interface if the plugin implements one,
	// or nil if it does not. A Pre-filter plugin can provide extensions to incrementally
	// modify its pre-processed info. The framework guarantees that the extensions
	// AddPod/RemovePod will only be called after PreFilter, possibly on a cloned
	// CycleState, and may call those functions more than once before calling
	// Filter again on a specific node.
	PreFilterExtensions() PreFilterExtensions
}

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

type PreScorePlugin added in v1.18.0

type PreScorePlugin interface {
	Plugin
	// PreScore is called by the scheduling framework after a list of nodes
	// passed the filtering phase. All prescore plugins must return success or
	// the pod will be rejected
	PreScore(ctx context.Context, state *CycleState, pod *v1.Pod, nodes []*v1.Node) *Status
}

PreScorePlugin is an interface for Pre-score plugin. Pre-score 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 ProtocolPort added in v1.19.0

type ProtocolPort struct {
	Protocol string
	Port     int32
}

ProtocolPort represents a protocol port pair, e.g. tcp:80.

func NewProtocolPort added in v1.19.0

func NewProtocolPort(protocol string, port int32) *ProtocolPort

NewProtocolPort creates a ProtocolPort instance.

type QueueSortPlugin

type QueueSortPlugin interface {
	Plugin
	// Less are used to sort pods in the scheduling queue.
	Less(*QueuedPodInfo, *QueuedPodInfo) 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 QueuedPodInfo added in v1.19.0

type QueuedPodInfo struct {
	Pod *v1.Pod
	// The time pod added to the scheduling queue.
	Timestamp time.Time
	// Number of schedule attempts before successfully scheduled.
	// It's used to record the # attempts metric.
	Attempts int
	// The time when the pod is added to the queue for the first time. The pod may be added
	// back to the queue multiple times before it's successfully scheduled.
	// It shouldn't be updated once initialized. It's used to record the e2e scheduling
	// latency for a pod.
	InitialAttemptTimestamp time.Time
}

QueuedPodInfo is a Pod wrapper with additional information related to the pod's status in the scheduling queue, such as the timestamp when it's added to the queue.

func (*QueuedPodInfo) DeepCopy added in v1.19.0

func (pqi *QueuedPodInfo) DeepCopy() *QueuedPodInfo

DeepCopy returns a deep copy of the QueuedPodInfo object.

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 (Registry) Merge added in v1.17.0

func (r Registry) Merge(in Registry) error

Merge merges the provided registry to the current one.

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(ctx context.Context, state *CycleState, 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 Resource added in v1.19.0

type Resource struct {
	MilliCPU         int64
	Memory           int64
	EphemeralStorage int64
	// We store allowedPodNumber (which is Node.Status.Allocatable.Pods().Value())
	// explicitly as int, to avoid conversions and improve performance.
	AllowedPodNumber int
	// ScalarResources
	ScalarResources map[v1.ResourceName]int64
}

Resource is a collection of compute resource.

func NewResource added in v1.19.0

func NewResource(rl v1.ResourceList) *Resource

NewResource creates a Resource from ResourceList

func (*Resource) Add added in v1.19.0

func (r *Resource) Add(rl v1.ResourceList)

Add adds ResourceList into Resource.

func (*Resource) AddScalar added in v1.19.0

func (r *Resource) AddScalar(name v1.ResourceName, quantity int64)

AddScalar adds a resource by a scalar value of this resource.

func (*Resource) Clone added in v1.19.0

func (r *Resource) Clone() *Resource

Clone returns a copy of this resource.

func (*Resource) ResourceList added in v1.19.0

func (r *Resource) ResourceList() v1.ResourceList

ResourceList returns a resource list of this resource.

func (*Resource) SetMaxResource added in v1.19.0

func (r *Resource) SetMaxResource(rl v1.ResourceList)

SetMaxResource compares with ResourceList and takes max value for each Resource.

func (*Resource) SetScalar added in v1.19.0

func (r *Resource) SetScalar(name v1.ResourceName, quantity int64)

SetScalar sets a resource by a scalar value of this resource.

type ScoreExtensions added in v1.17.0

type ScoreExtensions interface {
	// 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(ctx context.Context, state *CycleState, p *v1.Pod, scores NodeScoreList) *Status
}

ScoreExtensions is an interface for Score extended functionality.

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(ctx context.Context, state *CycleState, p *v1.Pod, nodeName string) (int64, *Status)

	// ScoreExtensions returns a ScoreExtensions interface if it implements one, or nil if does not.
	ScoreExtensions() ScoreExtensions
}

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

type SharedLister added in v1.19.0

type SharedLister interface {
	NodeInfos() NodeInfoLister
}

SharedLister groups scheduler-specific listers.

type StateData added in v1.17.0

type StateData interface {
	// Clone is an interface to make a copy of StateData. For performance reasons,
	// clone should make shallow copies for members (e.g., slices or maps) that are not
	// impacted by PreFilter's optional AddPod/RemovePod methods.
	Clone() StateData
}

StateData is a generic type for arbitrary data stored in CycleState.

type StateKey added in v1.17.0

type StateKey string

StateKey is the type of keys stored in CycleState.

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 reasons should explain why. NOTE: A nil Status is also considered as Success.

func NewStatus

func NewStatus(code Code, reasons ...string) *Status

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

func (*Status) AppendReason added in v1.18.0

func (s *Status) AppendReason(reason string)

AppendReason appends given reason to the Status.

func (*Status) AsError

func (s *Status) AsError() error

AsError returns nil if the status is a success; otherwise returns an "error" object with a concatenated message on reasons 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 a concatenated message on reasons of the Status.

func (*Status) Reasons added in v1.18.0

func (s *Status) Reasons() []string

Reasons returns reasons of the Status.

type TransientSchedulerInfo added in v1.19.0

type TransientSchedulerInfo struct {
	TransientLock sync.Mutex
	// NodeTransInfo holds the information related to nodeTransientInformation. NodeName is the key here.
	TransNodeInfo nodeTransientInfo
}

TransientSchedulerInfo is a transient structure which is destructed at the end of each scheduling cycle. It consists of items that are valid for a scheduling cycle and is used for message passing across predicates and priorities. Some examples which could be used as fields are number of volumes being used on node, current utilization on node etc. IMPORTANT NOTE: Make sure that each field in this structure is documented along with usage. Expand this structure only when absolutely needed as this data structure will be created and destroyed during every scheduling cycle.

func NewTransientSchedulerInfo added in v1.19.0

func NewTransientSchedulerInfo() *TransientSchedulerInfo

NewTransientSchedulerInfo returns a new scheduler transient structure with initialized values.

func (*TransientSchedulerInfo) ResetTransientSchedulerInfo added in v1.19.0

func (transientSchedInfo *TransientSchedulerInfo) ResetTransientSchedulerInfo()

ResetTransientSchedulerInfo resets the TransientSchedulerInfo.

type UnreservePlugin

type UnreservePlugin interface {
	Plugin
	// Unreserve is called by the scheduling framework when a reserved pod was
	// rejected in a later phase.
	Unreserve(ctx context.Context, state *CycleState, 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
	// GetPendingPlugins returns a list of pending permit plugin's name.
	GetPendingPlugins() []string
	// Allow declares the waiting pod is allowed to be scheduled by plugin pluginName.
	// If this is the last remaining plugin to allow, then a success signal is delivered
	// to unblock the pod.
	Allow(pluginName string)
	// Reject declares the waiting pod unschedulable.
	Reject(msg string)
}

WaitingPod represents a pod currently waiting in the permit phase.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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