package scheduler
import "github.com/moby/swarmkit/v2/manager/scheduler"
Index ¶
- func IsInTopology(top *api.Topology, accessible []*api.Topology) bool
- type ConstraintFilter
- func (f *ConstraintFilter) Check(n *NodeInfo) bool
- func (f *ConstraintFilter) Explain(nodes int) string
- func (f *ConstraintFilter) SetTask(t *api.Task) bool
- type Filter
- type HostPortFilter
- func (f *HostPortFilter) Check(n *NodeInfo) bool
- func (f *HostPortFilter) Explain(nodes int) string
- func (f *HostPortFilter) SetTask(t *api.Task) bool
- type MaxReplicasFilter
- func (f *MaxReplicasFilter) Check(n *NodeInfo) bool
- func (f *MaxReplicasFilter) Explain(nodes int) string
- func (f *MaxReplicasFilter) SetTask(t *api.Task) bool
- type NodeInfo
- type Pipeline
- func NewPipeline() *Pipeline
- func (p *Pipeline) AddFilter(f Filter)
- func (p *Pipeline) Explain() string
- func (p *Pipeline) Process(n *NodeInfo) bool
- func (p *Pipeline) SetTask(t *api.Task)
- type PlatformFilter
- func (f *PlatformFilter) Check(n *NodeInfo) bool
- func (f *PlatformFilter) Explain(nodes int) string
- func (f *PlatformFilter) SetTask(t *api.Task) bool
- type PluginFilter
- func (f *PluginFilter) Check(n *NodeInfo) bool
- func (f *PluginFilter) Explain(nodes int) string
- func (f *PluginFilter) SetTask(t *api.Task) bool
- type ReadyFilter
- func (f *ReadyFilter) Check(n *NodeInfo) bool
- func (f *ReadyFilter) Explain(nodes int) string
- func (f *ReadyFilter) SetTask(_ *api.Task) bool
- type ResourceFilter
- func (f *ResourceFilter) Check(n *NodeInfo) bool
- func (f *ResourceFilter) Explain(nodes int) string
- func (f *ResourceFilter) SetTask(t *api.Task) bool
- type Scheduler
- func New(store *store.MemoryStore) *Scheduler
- func (s *Scheduler) Run(pctx context.Context) error
- func (s *Scheduler) Stop()
- type VolumesFilter
Functions ¶
func IsInTopology ¶
IsInTopology takes a Topology `top` (which is reported by a Node) and a list of Topologies `accessible` (which comes from a created volume, in the form of the AccessibleTopology) and returns true if `top` lies within `accessible` (meaning a node with that Topology can access a volume with that AccessibleTopology).
In order for `top` to lie within `accessible`, there must exist a topology in `accessible` such that for every subdomain/segment pair in that topology, there exists an equivalent subdomain/segment pair in `top`.
For examples, see the test for this function.
NOTE(dperny): It is unclear whether a topology can be partial. For example, can an accessible topology contain only a "region" subdomain, without a "zone" subdomain? This function assumes yes.
Types ¶
type ConstraintFilter ¶
type ConstraintFilter struct {
// contains filtered or unexported fields
}
ConstraintFilter selects only nodes that match certain labels.
func (*ConstraintFilter) Check ¶
func (f *ConstraintFilter) Check(n *NodeInfo) bool
Check returns true if the task's constraint is supported by the given node.
func (*ConstraintFilter) Explain ¶
func (f *ConstraintFilter) Explain(nodes int) string
Explain returns an explanation of a failure.
func (*ConstraintFilter) SetTask ¶
func (f *ConstraintFilter) SetTask(t *api.Task) bool
SetTask returns true when the filter is enable for a given task.
type Filter ¶
type Filter interface { // SetTask returns true when the filter is enabled for a given task // and assigns the task to the filter. It returns false if the filter // isn't applicable to this task. For instance, a constraints filter // would return `false` if the task doesn't contain any constraints. SetTask(*api.Task) bool // Check returns true if the task assigned by SetTask can be scheduled // into the given node. This function should not be called if SetTask // returned false. Check(*NodeInfo) bool // Explain what a failure of this filter means Explain(nodes int) string }
Filter checks whether the given task can run on the given node. A filter may only operate
type HostPortFilter ¶
type HostPortFilter struct {
// contains filtered or unexported fields
}
HostPortFilter checks that the node has a specific port available.
func (*HostPortFilter) Check ¶
func (f *HostPortFilter) Check(n *NodeInfo) bool
Check returns true if the task can be scheduled into the given node.
func (*HostPortFilter) Explain ¶
func (f *HostPortFilter) Explain(nodes int) string
Explain returns an explanation of a failure.
func (*HostPortFilter) SetTask ¶
func (f *HostPortFilter) SetTask(t *api.Task) bool
SetTask returns true when the filter is enabled for a given task.
type MaxReplicasFilter ¶
type MaxReplicasFilter struct {
// contains filtered or unexported fields
}
MaxReplicasFilter selects only nodes that does not exceed max replicas per node.
func (*MaxReplicasFilter) Check ¶
func (f *MaxReplicasFilter) Check(n *NodeInfo) bool
Check returns true if there is less active (assigned or pre-assigned) tasks for this service on current node than set to MaxReplicas limit
func (*MaxReplicasFilter) Explain ¶
func (f *MaxReplicasFilter) Explain(nodes int) string
Explain returns an explanation of a failure.
func (*MaxReplicasFilter) SetTask ¶
func (f *MaxReplicasFilter) SetTask(t *api.Task) bool
SetTask returns true when max replicas per node filter > 0 for a given task.
type NodeInfo ¶
type NodeInfo struct { *api.Node Tasks map[string]*api.Task ActiveTasksCount int ActiveTasksCountByService map[string]int AvailableResources *api.Resources // contains filtered or unexported fields }
NodeInfo contains a node and some additional metadata.
type Pipeline ¶
type Pipeline struct {
// contains filtered or unexported fields
}
Pipeline runs a set of filters against nodes.
func NewPipeline ¶
func NewPipeline() *Pipeline
NewPipeline returns a pipeline with the default set of filters.
func (*Pipeline) AddFilter ¶
func (*Pipeline) Explain ¶
Explain returns a string explaining why a task could not be scheduled.
func (*Pipeline) Process ¶
Process a node through the filter pipeline. Returns true if all filters pass, false otherwise.
func (*Pipeline) SetTask ¶
SetTask sets up the filters to process a new task. Once this is called, Process can be called repeatedly to try to assign the task various nodes.
type PlatformFilter ¶
type PlatformFilter struct {
// contains filtered or unexported fields
}
PlatformFilter selects only nodes that run the required platform.
func (*PlatformFilter) Check ¶
func (f *PlatformFilter) Check(n *NodeInfo) bool
Check returns true if the task can be scheduled into the given node.
func (*PlatformFilter) Explain ¶
func (f *PlatformFilter) Explain(nodes int) string
Explain returns an explanation of a failure.
func (*PlatformFilter) SetTask ¶
func (f *PlatformFilter) SetTask(t *api.Task) bool
SetTask returns true when the filter is enabled for a given task.
type PluginFilter ¶
type PluginFilter struct {
// contains filtered or unexported fields
}
PluginFilter checks that the node has a specific volume plugin installed
func (*PluginFilter) Check ¶
func (f *PluginFilter) Check(n *NodeInfo) bool
Check returns true if the task can be scheduled into the given node. TODO(amitshukla): investigate storing Plugins as a map so it can be easily probed
func (*PluginFilter) Explain ¶
func (f *PluginFilter) Explain(nodes int) string
Explain returns an explanation of a failure.
func (*PluginFilter) SetTask ¶
func (f *PluginFilter) SetTask(t *api.Task) bool
SetTask returns true when the filter is enabled for a given task.
type ReadyFilter ¶
type ReadyFilter struct { }
ReadyFilter checks that the node is ready to schedule tasks.
func (*ReadyFilter) Check ¶
func (f *ReadyFilter) Check(n *NodeInfo) bool
Check returns true if the task can be scheduled into the given node.
func (*ReadyFilter) Explain ¶
func (f *ReadyFilter) Explain(nodes int) string
Explain returns an explanation of a failure.
func (*ReadyFilter) SetTask ¶
func (f *ReadyFilter) SetTask(_ *api.Task) bool
SetTask returns true when the filter is enabled for a given task.
type ResourceFilter ¶
type ResourceFilter struct {
// contains filtered or unexported fields
}
ResourceFilter checks that the node has enough resources available to run the task.
func (*ResourceFilter) Check ¶
func (f *ResourceFilter) Check(n *NodeInfo) bool
Check returns true if the task can be scheduled into the given node.
func (*ResourceFilter) Explain ¶
func (f *ResourceFilter) Explain(nodes int) string
Explain returns an explanation of a failure.
func (*ResourceFilter) SetTask ¶
func (f *ResourceFilter) SetTask(t *api.Task) bool
SetTask returns true when the filter is enabled for a given task.
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler assigns tasks to nodes.
func New ¶
func New(store *store.MemoryStore) *Scheduler
New creates a new scheduler.
func (*Scheduler) Run ¶
Run is the scheduler event loop.
func (*Scheduler) Stop ¶
func (s *Scheduler) Stop()
Stop causes the scheduler event loop to stop running.
type VolumesFilter ¶
type VolumesFilter struct {
// contains filtered or unexported fields
}
func (*VolumesFilter) Check ¶
func (f *VolumesFilter) Check(nodeInfo *NodeInfo) bool
func (*VolumesFilter) Explain ¶
func (f *VolumesFilter) Explain(nodes int) string
func (*VolumesFilter) SetTask ¶
func (f *VolumesFilter) SetTask(t *api.Task) bool
Source Files ¶
decision_tree.go filter.go nodeheap.go nodeinfo.go nodeset.go pipeline.go scheduler.go topology.go volumes.go
- Version
- v2.0.0-20250103191802-8c1959736554 (latest)
- Published
- Jan 3, 2025
- Platform
- linux/amd64
- Imports
- 15 packages
- Last checked
- 1 week ago –
Tools for package owners.