Documentation ¶
Index ¶
- Constants
- func DecodeInto(obj runtime.Object, into interface{}) error
- func GetPodKey(pod *v1.Pod) (string, error)
- func NewFramework(r Registry, client clientset.Interface, sharedLister SharedLister, ...) (framework, error)
- type Code
- type CycleState
- func (c *CycleState) Clone() *CycleState
- func (c *CycleState) Delete(key StateKey)
- func (c *CycleState) Lock()
- func (c *CycleState) RLock()
- func (c *CycleState) RUnlock()
- func (c *CycleState) Read(key StateKey) (StateData, error)
- func (c *CycleState) SetRecordPluginMetrics(flag bool)
- func (c *CycleState) ShouldRecordPluginMetrics() bool
- func (c *CycleState) Unlock()
- func (c *CycleState) Write(key StateKey, val StateData)
- type FilterPlugin
- type Framework
- type FrameworkHandle
- type HostPortInfo
- type ImageStateSummary
- type NodeInfo
- func (n *NodeInfo) AddPod(pod *v1.Pod)
- func (n *NodeInfo) Clone() *NodeInfo
- func (n *NodeInfo) FilterOutPods(pods []*v1.Pod) []*v1.Pod
- func (n *NodeInfo) Node() *v1.Node
- func (n *NodeInfo) RemovePod(pod *v1.Pod) error
- func (n *NodeInfo) SetNode(node *v1.Node) error
- func (n *NodeInfo) String() string
- type NodeInfoLister
- type NodeScore
- type NodeScoreList
- type Plugin
- type PluginFactory
- type PluginToNodeScores
- type PluginToStatus
- type PodInfo
- type PreFilterPlugin
- type PreScorePlugin
- type ProtocolPort
- type Registry
- type Resource
- func (r *Resource) Add(rl v1.ResourceList)
- func (r *Resource) AddScalar(name v1.ResourceName, quantity int64)
- func (r *Resource) Clone() *Resource
- func (r *Resource) ResourceList() v1.ResourceList
- func (r *Resource) SetMaxResource(rl v1.ResourceList)
- func (r *Resource) SetScalar(name v1.ResourceName, quantity int64)
- type ScoreExtensions
- type ScorePlugin
- type SharedLister
- type StateData
- type StateKey
- type Status
- type TransientSchedulerInfo
Constants ¶
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 )
const DefaultBindAllHostIP = "0.0.0.0"
DefaultBindAllHostIP defines the default ip address used to bind to all host.
const (
// NotFound is the not found error message.
NotFound = "not found"
)
Variables ¶
This section is empty.
Functions ¶
func DecodeInto ¶
DecodeInto decodes configuration whose type is *runtime.Unknown to the interface into.
func NewFramework ¶
func NewFramework( r Registry, client clientset.Interface, sharedLister SharedLister, volumeBinder scheduling.SchedulerVolumeBinder) (framework, error)
Creates a new framework struct
Types ¶
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 CycleState ¶
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 ¶
func NewCycleState() *CycleState
NewCycleState initializes a new CycleState and returns its pointer.
func (*CycleState) Clone ¶
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 ¶
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) Read ¶
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 ¶
func (c *CycleState) SetRecordPluginMetrics(flag bool)
SetRecordPluginMetrics sets recordPluginMetrics to the given value.
func (*CycleState) ShouldRecordPluginMetrics ¶
func (c *CycleState) ShouldRecordPluginMetrics() bool
ShouldRecordPluginMetrics returns whether PluginExecutionDuration metrics should be recorded.
func (*CycleState) Write ¶
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 ¶
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 // 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 // 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 // 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) }
Framework manages the set of plugins in use by the scheduling framework. Configured plugins are called at specified points in a scheduling context.
type FrameworkHandle ¶
type FrameworkHandle interface { // ClientSet returns a kubernetes clientSet. ClientSet() clientset.Interface // 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 // VolumeBinder returns the volume binder used by scheduler. VolumeBinder() scheduling.SchedulerVolumeBinder // Get current highest repeat factory among all the nodes in the cluster for this scheduler instance. GetHighestUsageFactor() int // Get current repeat factory of a node. GetNodeUsageFactor(nodeName string) int // Increase repeat factor of a specific node. IncreaseNodeUsageFactor(nodeName string) }
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 ¶
type HostPortInfo map[string]map[ProtocolPort]struct{}
HostPortInfo stores mapping from ip to a set of ProtocolPort
func (HostPortInfo) Add ¶
func (h HostPortInfo) Add(ip, protocol string, port int32)
Add adds (ip, protocol, port) to HostPortInfo
func (HostPortInfo) CheckConflict ¶
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 ¶
func (h HostPortInfo) Len() int
Len returns the total number of (ip, protocol, port) tuple in HostPortInfo
func (HostPortInfo) Remove ¶
func (h HostPortInfo) Remove(ip, protocol string, port int32)
Remove removes (ip, protocol, port) from HostPortInfo
type ImageStateSummary ¶
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 NodeInfo ¶
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 ¶
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) FilterOutPods ¶
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.
type NodeInfoLister ¶
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 NodeScoreList ¶
type NodeScoreList []NodeScore
NodeScoreList declares a list of nodes and their scores.
type Plugin ¶
type Plugin interface {
Name() string
}
Plugin is the parent type for all the scheduling framework plugins.
type PluginFactory ¶
type PluginFactory = func(obj runtime.Object, f FrameworkHandle) (Plugin, error)
PluginFactory is a function that builds a plugin.
type PluginToNodeScores ¶
type PluginToNodeScores map[string]NodeScoreList
PluginToNodeScores declares a map from plugin name to its NodeScoreList.
type PluginToStatus ¶
PluginToStatus maps plugin name to status. Currently used to identify which Filter plugin returned which status.
func (PluginToStatus) Merge ¶
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 ¶
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).
type PreFilterPlugin ¶
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 }
PreFilterPlugin is an interface that must be implemented by "prefilter" plugins. These plugins are called at the beginning of the scheduling cycle.
type PreScorePlugin ¶
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 ¶
ProtocolPort represents a protocol port pair, e.g. tcp:80.
func NewProtocolPort ¶
func NewProtocolPort(protocol string, port int32) *ProtocolPort
NewProtocolPort creates a ProtocolPort instance.
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.
type Resource ¶
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 ¶
func NewResource(rl v1.ResourceList) *Resource
NewResource creates a Resource from ResourceList
func (*Resource) Add ¶
func (r *Resource) Add(rl v1.ResourceList)
Add adds ResourceList into Resource.
func (*Resource) AddScalar ¶
func (r *Resource) AddScalar(name v1.ResourceName, quantity int64)
AddScalar adds a resource by a scalar value of this resource.
func (*Resource) ResourceList ¶
func (r *Resource) ResourceList() v1.ResourceList
ResourceList returns a resource list of this resource.
func (*Resource) SetMaxResource ¶
func (r *Resource) SetMaxResource(rl v1.ResourceList)
SetMaxResource compares with ResourceList and takes max value for each Resource.
type ScoreExtensions ¶
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 ¶
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) }
ScorePlugin is an interface that must be implemented by "score" plugins to rank nodes that passed the filtering phase.
type StateData ¶
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 Status ¶
type Status struct {
// contains filtered or unexported fields
}
Status contain the status and also the reasons for causing this status.
func (*Status) AppendReason ¶
AppendReason appends given reason to the Status.
func (*Status) IsSuccess ¶
IsSuccess returns true if and only if "Status" is nil or Code is "Success".
func (*Status) IsUnschedulable ¶
IsUnschedulable returns true if "Status" is Unschedulable (Unschedulable or UnschedulableAndUnresolvable).
type TransientSchedulerInfo ¶
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 ¶
func NewTransientSchedulerInfo() *TransientSchedulerInfo
NewTransientSchedulerInfo returns a new scheduler transient structure with initialized values.
func (*TransientSchedulerInfo) ResetTransientSchedulerInfo ¶
func (transientSchedInfo *TransientSchedulerInfo) ResetTransientSchedulerInfo()
ResetTransientSchedulerInfo resets the TransientSchedulerInfo.