Documentation ¶
Index ¶
- Constants
- Variables
- func Annotate(diff *structs.JobDiff, annotations *structs.PlanAnnotations) error
- func NewPropertySet(ctx Context, job *structs.Job) *propertySet
- type BinPackIterator
- type ComputedClassFeasibility
- type ConstraintChecker
- type Context
- type DistinctHostsIterator
- type DistinctPropertyIterator
- type DriverChecker
- type EvalCache
- type EvalContext
- func (e *EvalContext) Eligibility() *EvalEligibility
- func (e *EvalContext) Logger() *log.Logger
- func (e *EvalContext) Metrics() *structs.AllocMetric
- func (e *EvalContext) Plan() *structs.Plan
- func (e *EvalContext) ProposedAllocs(nodeID string) ([]*structs.Allocation, error)
- func (e *EvalContext) Reset()
- func (e *EvalContext) SetState(s State)
- func (e *EvalContext) State() State
- type EvalEligibility
- func (e *EvalEligibility) GetClasses() map[string]bool
- func (e *EvalEligibility) HasEscaped() bool
- func (e *EvalEligibility) JobStatus(class string) ComputedClassFeasibility
- func (e *EvalEligibility) SetJob(job *structs.Job)
- func (e *EvalEligibility) SetJobEligibility(eligible bool, class string)
- func (e *EvalEligibility) SetTaskGroupEligibility(eligible bool, tg, class string)
- func (e *EvalEligibility) TaskGroupStatus(tg, class string) ComputedClassFeasibility
- type Factory
- type FeasibilityChecker
- type FeasibilityWrapper
- type FeasibleIterator
- type FeasibleRankIterator
- type GenericScheduler
- type GenericStack
- func (s *GenericStack) Select(tg *structs.TaskGroup) (*RankedNode, *structs.Resources)
- func (s *GenericStack) SelectPreferringNodes(tg *structs.TaskGroup, nodes []*structs.Node) (*RankedNode, *structs.Resources)
- func (s *GenericStack) SetJob(job *structs.Job)
- func (s *GenericStack) SetNodes(baseNodes []*structs.Node)
- type Harness
- func (h *Harness) AssertEvalStatus(t *testing.T, state string)
- func (h *Harness) CreateEval(eval *structs.Evaluation) error
- func (h *Harness) NextIndex() uint64
- func (h *Harness) Process(factory Factory, eval *structs.Evaluation) error
- func (h *Harness) ReblockEval(eval *structs.Evaluation) error
- func (h *Harness) Scheduler(factory Factory) Scheduler
- func (h *Harness) Snapshot() State
- func (h *Harness) SubmitPlan(plan *structs.Plan) (*structs.PlanResult, State, error)
- func (h *Harness) UpdateEval(eval *structs.Evaluation) error
- type JobAntiAffinityIterator
- type LimitIterator
- type MaxScoreIterator
- type Planner
- type RankIterator
- type RankedNode
- type RejectPlan
- type Scheduler
- func NewBatchScheduler(logger *log.Logger, state State, planner Planner) Scheduler
- func NewScheduler(name string, logger *log.Logger, state State, planner Planner) (Scheduler, error)
- func NewServiceScheduler(logger *log.Logger, state State, planner Planner) Scheduler
- func NewSystemScheduler(logger *log.Logger, state State, planner Planner) Scheduler
- type SetStatusError
- type Stack
- type State
- type StaticIterator
- type StaticRankIterator
- type SystemScheduler
- type SystemStack
Constants ¶
const ( AnnotationForcesCreate = "forces create" AnnotationForcesDestroy = "forces destroy" AnnotationForcesInplaceUpdate = "forces in-place update" AnnotationForcesDestructiveUpdate = "forces create/destroy update" )
const ( UpdateTypeIgnore = "ignore" UpdateTypeCreate = "create" UpdateTypeDestroy = "destroy" UpdateTypeMigrate = "migrate" UpdateTypeInplaceUpdate = "in-place update" UpdateTypeDestructiveUpdate = "create/destroy update" )
UpdateTypes denote the type of update to occur against the task group.
const ( // SchedulerVersion is the version of the scheduler. Changes to the // scheduler that are incompatible with prior schedulers will increment this // version. It is used to disallow dequeueing when the versions do not match // across the leader and the dequeueing scheduler. SchedulerVersion uint16 = 1 )
Variables ¶
var BuiltinSchedulers = map[string]Factory{ "service": NewServiceScheduler, "batch": NewBatchScheduler, "system": NewSystemScheduler, }
BuiltinSchedulers contains the built in registered schedulers which are available
Functions ¶
func Annotate ¶ added in v0.4.0
func Annotate(diff *structs.JobDiff, annotations *structs.PlanAnnotations) error
Annotate takes the diff between the old and new version of a Job, the scheduler's plan annotations and will add annotations to the diff to aide human understanding of the plan.
Currently the things that are annotated are: * Task group changes will be annotated with:
- Count up and count down changes
- Update counts (creates, destroys, migrates, etc)
* Task changes will be annotated with:
- forces create/destroy update
- forces in-place update
func NewPropertySet ¶ added in v0.5.5
NewPropertySet returns a new property set used to guarantee unique property values for new allocation placements.
Types ¶
type BinPackIterator ¶
type BinPackIterator struct {
// contains filtered or unexported fields
}
BinPackIterator is a RankIterator that scores potential options based on a bin-packing algorithm.
func NewBinPackIterator ¶
func NewBinPackIterator(ctx Context, source RankIterator, evict bool, priority int) *BinPackIterator
NewBinPackIterator returns a BinPackIterator which tries to fit tasks potentially evicting other tasks based on a given priority.
func (*BinPackIterator) Next ¶
func (iter *BinPackIterator) Next() *RankedNode
func (*BinPackIterator) Reset ¶
func (iter *BinPackIterator) Reset()
func (*BinPackIterator) SetPriority ¶
func (iter *BinPackIterator) SetPriority(p int)
func (*BinPackIterator) SetTaskGroup ¶ added in v0.5.0
func (iter *BinPackIterator) SetTaskGroup(taskGroup *structs.TaskGroup)
type ComputedClassFeasibility ¶ added in v0.3.0
type ComputedClassFeasibility byte
const ( // EvalComputedClassUnknown is the initial state until the eligibility has // been explicitly marked to eligible/ineligible or escaped. EvalComputedClassUnknown ComputedClassFeasibility = iota // EvalComputedClassIneligible is used to mark the computed class as // ineligible for the evaluation. EvalComputedClassIneligible // EvalComputedClassIneligible is used to mark the computed class as // eligible for the evaluation. EvalComputedClassEligible // EvalComputedClassEscaped signals that computed class can not determine // eligibility because a constraint exists that is not captured by computed // node classes. EvalComputedClassEscaped )
type ConstraintChecker ¶ added in v0.3.0
type ConstraintChecker struct {
// contains filtered or unexported fields
}
ConstraintChecker is a FeasibilityChecker which returns nodes that match a given set of constraints. This is used to filter on job, task group, and task constraints.
func NewConstraintChecker ¶ added in v0.3.0
func NewConstraintChecker(ctx Context, constraints []*structs.Constraint) *ConstraintChecker
NewConstraintChecker creates a ConstraintChecker for a set of constraints
func (*ConstraintChecker) Feasible ¶ added in v0.3.0
func (c *ConstraintChecker) Feasible(option *structs.Node) bool
func (*ConstraintChecker) SetConstraints ¶ added in v0.3.0
func (c *ConstraintChecker) SetConstraints(constraints []*structs.Constraint)
type Context ¶
type Context interface { // State is used to inspect the current global state State() State // Plan returns the current plan Plan() *structs.Plan // Logger provides a way to log Logger() *log.Logger // Metrics returns the current metrics Metrics() *structs.AllocMetric // Reset is invoked after making a placement Reset() // ProposedAllocs returns the proposed allocations for a node // which is the existing allocations, removing evictions, and // adding any planned placements. ProposedAllocs(nodeID string) ([]*structs.Allocation, error) // RegexpCache is a cache of regular expressions RegexpCache() map[string]*regexp.Regexp // ConstraintCache is a cache of version constraints ConstraintCache() map[string]version.Constraints // Eligibility returns a tracker for node eligibility in the context of the // eval. Eligibility() *EvalEligibility }
Context is used to track contextual information used for placement
type DistinctHostsIterator ¶ added in v0.5.5
type DistinctHostsIterator struct {
// contains filtered or unexported fields
}
DistinctHostsIterator is a FeasibleIterator which returns nodes that pass the distinct_hosts constraint. The constraint ensures that multiple allocations do not exist on the same node.
func NewDistinctHostsIterator ¶ added in v0.5.5
func NewDistinctHostsIterator(ctx Context, source FeasibleIterator) *DistinctHostsIterator
NewDistinctHostsIterator creates a DistinctHostsIterator from a source.
func (*DistinctHostsIterator) Next ¶ added in v0.5.5
func (iter *DistinctHostsIterator) Next() *structs.Node
func (*DistinctHostsIterator) Reset ¶ added in v0.5.5
func (iter *DistinctHostsIterator) Reset()
func (*DistinctHostsIterator) SetJob ¶ added in v0.5.5
func (iter *DistinctHostsIterator) SetJob(job *structs.Job)
func (*DistinctHostsIterator) SetTaskGroup ¶ added in v0.5.5
func (iter *DistinctHostsIterator) SetTaskGroup(tg *structs.TaskGroup)
type DistinctPropertyIterator ¶ added in v0.5.5
type DistinctPropertyIterator struct {
// contains filtered or unexported fields
}
DistinctPropertyIterator is a FeasibleIterator which returns nodes that pass the distinct_property constraint. The constraint ensures that multiple allocations do not use the same value of the given property.
func NewDistinctPropertyIterator ¶ added in v0.5.5
func NewDistinctPropertyIterator(ctx Context, source FeasibleIterator) *DistinctPropertyIterator
NewDistinctPropertyIterator creates a DistinctPropertyIterator from a source.
func (*DistinctPropertyIterator) Next ¶ added in v0.5.5
func (iter *DistinctPropertyIterator) Next() *structs.Node
func (*DistinctPropertyIterator) Reset ¶ added in v0.5.5
func (iter *DistinctPropertyIterator) Reset()
func (*DistinctPropertyIterator) SetJob ¶ added in v0.5.5
func (iter *DistinctPropertyIterator) SetJob(job *structs.Job)
func (*DistinctPropertyIterator) SetTaskGroup ¶ added in v0.5.5
func (iter *DistinctPropertyIterator) SetTaskGroup(tg *structs.TaskGroup)
type DriverChecker ¶ added in v0.3.0
type DriverChecker struct {
// contains filtered or unexported fields
}
DriverChecker is a FeasibilityChecker which returns whether a node has the drivers necessary to scheduler a task group.
func NewDriverChecker ¶ added in v0.3.0
func NewDriverChecker(ctx Context, drivers map[string]struct{}) *DriverChecker
NewDriverChecker creates a DriverChecker from a set of drivers
func (*DriverChecker) Feasible ¶ added in v0.3.0
func (c *DriverChecker) Feasible(option *structs.Node) bool
func (*DriverChecker) SetDrivers ¶ added in v0.3.0
func (c *DriverChecker) SetDrivers(d map[string]struct{})
type EvalCache ¶ added in v0.2.0
type EvalCache struct {
// contains filtered or unexported fields
}
EvalCache is used to cache certain things during an evaluation
func (*EvalCache) ConstraintCache ¶ added in v0.2.0
type EvalContext ¶
type EvalContext struct { EvalCache // contains filtered or unexported fields }
EvalContext is a Context used during an Evaluation
func NewEvalContext ¶
NewEvalContext constructs a new EvalContext
func (*EvalContext) Eligibility ¶ added in v0.3.0
func (e *EvalContext) Eligibility() *EvalEligibility
func (*EvalContext) Logger ¶
func (e *EvalContext) Logger() *log.Logger
func (*EvalContext) Metrics ¶
func (e *EvalContext) Metrics() *structs.AllocMetric
func (*EvalContext) Plan ¶
func (e *EvalContext) Plan() *structs.Plan
func (*EvalContext) ProposedAllocs ¶
func (e *EvalContext) ProposedAllocs(nodeID string) ([]*structs.Allocation, error)
func (*EvalContext) Reset ¶
func (e *EvalContext) Reset()
func (*EvalContext) SetState ¶
func (e *EvalContext) SetState(s State)
func (*EvalContext) State ¶
func (e *EvalContext) State() State
type EvalEligibility ¶ added in v0.3.0
type EvalEligibility struct {
// contains filtered or unexported fields
}
EvalEligibility tracks eligibility of nodes by computed node class over the course of an evaluation.
func NewEvalEligibility ¶ added in v0.3.0
func NewEvalEligibility() *EvalEligibility
NewEvalEligibility returns an eligibility tracker for the context of an evaluation.
func (*EvalEligibility) GetClasses ¶ added in v0.3.0
func (e *EvalEligibility) GetClasses() map[string]bool
GetClasses returns the tracked classes to their eligibility, across the job and task groups.
func (*EvalEligibility) HasEscaped ¶ added in v0.3.0
func (e *EvalEligibility) HasEscaped() bool
HasEscaped returns whether any of the constraints in the passed job have escaped computed node classes.
func (*EvalEligibility) JobStatus ¶ added in v0.3.0
func (e *EvalEligibility) JobStatus(class string) ComputedClassFeasibility
JobStatus returns the eligibility status of the job.
func (*EvalEligibility) SetJob ¶ added in v0.3.0
func (e *EvalEligibility) SetJob(job *structs.Job)
SetJob takes the job being evaluated and calculates the escaped constraints at the job and task group level.
func (*EvalEligibility) SetJobEligibility ¶ added in v0.3.0
func (e *EvalEligibility) SetJobEligibility(eligible bool, class string)
SetJobEligibility sets the eligibility status of the job for the computed node class.
func (*EvalEligibility) SetTaskGroupEligibility ¶ added in v0.3.0
func (e *EvalEligibility) SetTaskGroupEligibility(eligible bool, tg, class string)
SetTaskGroupEligibility sets the eligibility status of the task group for the computed node class.
func (*EvalEligibility) TaskGroupStatus ¶ added in v0.3.0
func (e *EvalEligibility) TaskGroupStatus(tg, class string) ComputedClassFeasibility
TaskGroupStatus returns the eligibility status of the task group.
type FeasibilityChecker ¶ added in v0.3.0
FeasibilityChecker is used to check if a single node meets feasibility constraints.
type FeasibilityWrapper ¶ added in v0.3.0
type FeasibilityWrapper struct {
// contains filtered or unexported fields
}
FeasibilityWrapper is a FeasibleIterator which wraps both job and task group FeasibilityCheckers in which feasibility checking can be skipped if the computed node class has previously been marked as eligible or ineligible.
func NewFeasibilityWrapper ¶ added in v0.3.0
func NewFeasibilityWrapper(ctx Context, source FeasibleIterator, jobCheckers, tgCheckers []FeasibilityChecker) *FeasibilityWrapper
NewFeasibilityWrapper returns a FeasibleIterator based on the passed source and FeasibilityCheckers.
func (*FeasibilityWrapper) Next ¶ added in v0.3.0
func (w *FeasibilityWrapper) Next() *structs.Node
Next returns an eligible node, only running the FeasibilityCheckers as needed based on the sources computed node class.
func (*FeasibilityWrapper) Reset ¶ added in v0.3.0
func (w *FeasibilityWrapper) Reset()
func (*FeasibilityWrapper) SetTaskGroup ¶ added in v0.3.0
func (w *FeasibilityWrapper) SetTaskGroup(tg string)
type FeasibleIterator ¶
type FeasibleIterator interface { // Next yields a feasible node or nil if exhausted Next() *structs.Node // Reset is invoked when an allocation has been placed // to reset any stale state. Reset() }
FeasibleIterator is used to iteratively yield nodes that match feasibility constraints. The iterators may manage some state for performance optimizations.
type FeasibleRankIterator ¶
type FeasibleRankIterator struct {
// contains filtered or unexported fields
}
FeasibleRankIterator is used to consume from a FeasibleIterator and return an unranked node with base ranking.
func NewFeasibleRankIterator ¶
func NewFeasibleRankIterator(ctx Context, source FeasibleIterator) *FeasibleRankIterator
NewFeasibleRankIterator is used to return a new FeasibleRankIterator from a FeasibleIterator source.
func (*FeasibleRankIterator) Next ¶
func (iter *FeasibleRankIterator) Next() *RankedNode
func (*FeasibleRankIterator) Reset ¶
func (iter *FeasibleRankIterator) Reset()
type GenericScheduler ¶
type GenericScheduler struct {
// contains filtered or unexported fields
}
GenericScheduler is used for 'service' and 'batch' type jobs. This scheduler is designed for long-lived services, and as such spends more time attemping to make a high quality placement. This is the primary scheduler for most workloads. It also supports a 'batch' mode to optimize for fast decision making at the cost of quality.
func (*GenericScheduler) Process ¶
func (s *GenericScheduler) Process(eval *structs.Evaluation) error
Process is used to handle a single evaluation
type GenericStack ¶
type GenericStack struct {
// contains filtered or unexported fields
}
GenericStack is the Stack used for the Generic scheduler. It is designed to make better placement decisions at the cost of performance.
func NewGenericStack ¶
func NewGenericStack(batch bool, ctx Context) *GenericStack
NewGenericStack constructs a stack used for selecting service placements
func (*GenericStack) Select ¶
func (s *GenericStack) Select(tg *structs.TaskGroup) (*RankedNode, *structs.Resources)
func (*GenericStack) SelectPreferringNodes ¶ added in v0.5.0
func (s *GenericStack) SelectPreferringNodes(tg *structs.TaskGroup, nodes []*structs.Node) (*RankedNode, *structs.Resources)
SelectPreferredNode returns a node where an allocation of the task group can be placed, the node passed to it is preferred over the other available nodes
func (*GenericStack) SetJob ¶
func (s *GenericStack) SetJob(job *structs.Job)
func (*GenericStack) SetNodes ¶
func (s *GenericStack) SetNodes(baseNodes []*structs.Node)
type Harness ¶ added in v0.4.0
type Harness struct { State *state.StateStore Planner Planner Plans []*structs.Plan Evals []*structs.Evaluation CreateEvals []*structs.Evaluation ReblockEvals []*structs.Evaluation // contains filtered or unexported fields }
Harness is a lightweight testing harness for schedulers. It manages a state store copy and provides the planner interface. It can be extended for various testing uses or for invoking the scheduler without side effects.
func NewHarness ¶ added in v0.4.0
NewHarness is used to make a new testing harness
func NewHarnessWithState ¶ added in v0.5.0
func NewHarnessWithState(t *testing.T, state *state.StateStore) *Harness
NewHarnessWithState creates a new harness with the given state for testing purposes.
func (*Harness) AssertEvalStatus ¶ added in v0.4.0
func (*Harness) CreateEval ¶ added in v0.4.0
func (h *Harness) CreateEval(eval *structs.Evaluation) error
func (*Harness) Process ¶ added in v0.4.0
func (h *Harness) Process(factory Factory, eval *structs.Evaluation) error
Process is used to process an evaluation given a factory function to create the scheduler
func (*Harness) ReblockEval ¶ added in v0.4.0
func (h *Harness) ReblockEval(eval *structs.Evaluation) error
func (*Harness) Scheduler ¶ added in v0.4.0
Scheduler is used to return a new scheduler from a snapshot of current state using the harness for planning.
func (*Harness) SubmitPlan ¶ added in v0.4.0
SubmitPlan is used to handle plan submission
func (*Harness) UpdateEval ¶ added in v0.4.0
func (h *Harness) UpdateEval(eval *structs.Evaluation) error
type JobAntiAffinityIterator ¶
type JobAntiAffinityIterator struct {
// contains filtered or unexported fields
}
JobAntiAffinityIterator is used to apply an anti-affinity to allocating along side other allocations from this job. This is used to help distribute load across the cluster.
func NewJobAntiAffinityIterator ¶
func NewJobAntiAffinityIterator(ctx Context, source RankIterator, penalty float64, jobID string) *JobAntiAffinityIterator
NewJobAntiAffinityIterator is used to create a JobAntiAffinityIterator that applies the given penalty for co-placement with allocs from this job.
func (*JobAntiAffinityIterator) Next ¶
func (iter *JobAntiAffinityIterator) Next() *RankedNode
func (*JobAntiAffinityIterator) Reset ¶
func (iter *JobAntiAffinityIterator) Reset()
func (*JobAntiAffinityIterator) SetJob ¶
func (iter *JobAntiAffinityIterator) SetJob(jobID string)
type LimitIterator ¶
type LimitIterator struct {
// contains filtered or unexported fields
}
LimitIterator is a RankIterator used to limit the number of options that are returned before we artificially end the stream.
func NewLimitIterator ¶
func NewLimitIterator(ctx Context, source RankIterator, limit int) *LimitIterator
NewLimitIterator is returns a LimitIterator with a fixed limit of returned options
func (*LimitIterator) Next ¶
func (iter *LimitIterator) Next() *RankedNode
func (*LimitIterator) Reset ¶
func (iter *LimitIterator) Reset()
func (*LimitIterator) SetLimit ¶
func (iter *LimitIterator) SetLimit(limit int)
type MaxScoreIterator ¶
type MaxScoreIterator struct {
// contains filtered or unexported fields
}
MaxScoreIterator is a RankIterator used to return only a single result of the item with the highest score. This iterator will consume all of the possible inputs and only returns the highest ranking result.
func NewMaxScoreIterator ¶
func NewMaxScoreIterator(ctx Context, source RankIterator) *MaxScoreIterator
MaxScoreIterator returns a MaxScoreIterator over the given source
func (*MaxScoreIterator) Next ¶
func (iter *MaxScoreIterator) Next() *RankedNode
func (*MaxScoreIterator) Reset ¶
func (iter *MaxScoreIterator) Reset()
type Planner ¶
type Planner interface { // SubmitPlan is used to submit a plan for consideration. // This will return a PlanResult or an error. It is possible // that this will result in a state refresh as well. SubmitPlan(*structs.Plan) (*structs.PlanResult, State, error) // UpdateEval is used to update an evaluation. This should update // a copy of the input evaluation since that should be immutable. UpdateEval(*structs.Evaluation) error // CreateEval is used to create an evaluation. This should set the // PreviousEval to that of the current evaluation. CreateEval(*structs.Evaluation) error // ReblockEval takes a blocked evaluation and re-inserts it into the blocked // evaluation tracker. This update occurs only in-memory on the leader. The // evaluation must exist in a blocked state prior to this being called such // that on leader changes, the evaluation will be reblocked properly. ReblockEval(*structs.Evaluation) error }
Planner interface is used to submit a task allocation plan.
type RankIterator ¶
type RankIterator interface { // Next yields a ranked option or nil if exhausted Next() *RankedNode // Reset is invoked when an allocation has been placed // to reset any stale state. Reset() }
RankFeasibleIterator is used to iteratively yield nodes along with ranking metadata. The iterators may manage some state for performance optimizations.
type RankedNode ¶
type RankedNode struct { Node *structs.Node Score float64 TaskResources map[string]*structs.Resources // Allocs is used to cache the proposed allocations on the // node. This can be shared between iterators that require it. Proposed []*structs.Allocation }
Rank is used to provide a score and various ranking metadata along with a node when iterating. This state can be modified as various rank methods are applied.
func (*RankedNode) GoString ¶
func (r *RankedNode) GoString() string
func (*RankedNode) ProposedAllocs ¶
func (r *RankedNode) ProposedAllocs(ctx Context) ([]*structs.Allocation, error)
func (*RankedNode) SetTaskResources ¶
func (r *RankedNode) SetTaskResources(task *structs.Task, resource *structs.Resources)
type RejectPlan ¶ added in v0.4.0
type RejectPlan struct {
Harness *Harness
}
RejectPlan is used to always reject the entire plan and force a state refresh
func (*RejectPlan) CreateEval ¶ added in v0.4.0
func (r *RejectPlan) CreateEval(*structs.Evaluation) error
func (*RejectPlan) ReblockEval ¶ added in v0.4.0
func (r *RejectPlan) ReblockEval(*structs.Evaluation) error
func (*RejectPlan) SubmitPlan ¶ added in v0.4.0
func (r *RejectPlan) SubmitPlan(*structs.Plan) (*structs.PlanResult, State, error)
func (*RejectPlan) UpdateEval ¶ added in v0.4.0
func (r *RejectPlan) UpdateEval(eval *structs.Evaluation) error
type Scheduler ¶
type Scheduler interface { // Process is used to handle a new evaluation. The scheduler is free to // apply any logic necessary to make the task placements. The state and // planner will be provided prior to any invocations of process. Process(*structs.Evaluation) error }
Scheduler is the top level instance for a scheduler. A scheduler is meant to only encapsulate business logic, pushing the various plumbing into Nomad itself. They are invoked to process a single evaluation at a time. The evaluation may result in task allocations which are computed optimistically, as there are many concurrent evaluations being processed. The task allocations are submitted as a plan, and the current leader will coordinate the commmits to prevent oversubscription or improper allocations based on stale state.
func NewBatchScheduler ¶
NewBatchScheduler is a factory function to instantiate a new batch scheduler
func NewScheduler ¶
NewScheduler is used to instantiate and return a new scheduler given the scheduler name, initial state, and planner.
func NewServiceScheduler ¶
NewServiceScheduler is a factory function to instantiate a new service scheduler
type SetStatusError ¶
SetStatusError is used to set the status of the evaluation to the given error
func (*SetStatusError) Error ¶
func (s *SetStatusError) Error() string
type Stack ¶
type Stack interface { // SetNodes is used to set the base set of potential nodes SetNodes([]*structs.Node) // SetTaskGroup is used to set the job for selection SetJob(job *structs.Job) // Select is used to select a node for the task group Select(tg *structs.TaskGroup) (*RankedNode, *structs.Resources) }
Stack is a chained collection of iterators. The stack is used to make placement decisions. Different schedulers may customize the stack they use to vary the way placements are made.
type State ¶
type State interface { // Nodes returns an iterator over all the nodes. // The type of each result is *structs.Node Nodes(ws memdb.WatchSet) (memdb.ResultIterator, error) // AllocsByJob returns the allocations by JobID AllocsByJob(ws memdb.WatchSet, jobID string, all bool) ([]*structs.Allocation, error) // AllocsByNode returns all the allocations by node AllocsByNode(ws memdb.WatchSet, node string) ([]*structs.Allocation, error) // AllocsByNodeTerminal returns all the allocations by node filtering by terminal status AllocsByNodeTerminal(ws memdb.WatchSet, node string, terminal bool) ([]*structs.Allocation, error) // GetNodeByID is used to lookup a node by ID NodeByID(ws memdb.WatchSet, nodeID string) (*structs.Node, error) // GetJobByID is used to lookup a job by ID JobByID(ws memdb.WatchSet, id string) (*structs.Job, error) }
State is an immutable view of the global state. This allows schedulers to make intelligent decisions based on allocations of other schedulers and to enforce complex constraints that require more information than is available to a local state scheduler.
type StaticIterator ¶
type StaticIterator struct {
// contains filtered or unexported fields
}
StaticIterator is a FeasibleIterator which returns nodes in a static order. This is used at the base of the iterator chain only for testing due to deterministic behavior.
func NewRandomIterator ¶
func NewRandomIterator(ctx Context, nodes []*structs.Node) *StaticIterator
NewRandomIterator constructs a static iterator from a list of nodes after applying the Fisher-Yates algorithm for a random shuffle. This is applied in-place
func NewStaticIterator ¶
func NewStaticIterator(ctx Context, nodes []*structs.Node) *StaticIterator
NewStaticIterator constructs a random iterator from a list of nodes
func (*StaticIterator) Next ¶
func (iter *StaticIterator) Next() *structs.Node
func (*StaticIterator) Reset ¶
func (iter *StaticIterator) Reset()
func (*StaticIterator) SetNodes ¶
func (iter *StaticIterator) SetNodes(nodes []*structs.Node)
type StaticRankIterator ¶
type StaticRankIterator struct {
// contains filtered or unexported fields
}
StaticRankIterator is a RankIterator that returns a static set of results. This is largely only useful for testing.
func NewStaticRankIterator ¶
func NewStaticRankIterator(ctx Context, nodes []*RankedNode) *StaticRankIterator
NewStaticRankIterator returns a new static rank iterator over the given nodes
func (*StaticRankIterator) Next ¶
func (iter *StaticRankIterator) Next() *RankedNode
func (*StaticRankIterator) Reset ¶
func (iter *StaticRankIterator) Reset()
type SystemScheduler ¶ added in v0.2.0
type SystemScheduler struct {
// contains filtered or unexported fields
}
SystemScheduler is used for 'system' jobs. This scheduler is designed for services that should be run on every client.
func (*SystemScheduler) Process ¶ added in v0.2.0
func (s *SystemScheduler) Process(eval *structs.Evaluation) error
Process is used to handle a single evaluation.
type SystemStack ¶ added in v0.2.0
type SystemStack struct {
// contains filtered or unexported fields
}
SystemStack is the Stack used for the System scheduler. It is designed to attempt to make placements on all nodes.
func NewSystemStack ¶ added in v0.2.0
func NewSystemStack(ctx Context) *SystemStack
NewSystemStack constructs a stack used for selecting service placements
func (*SystemStack) Select ¶ added in v0.2.0
func (s *SystemStack) Select(tg *structs.TaskGroup) (*RankedNode, *structs.Resources)
func (*SystemStack) SetJob ¶ added in v0.2.0
func (s *SystemStack) SetJob(job *structs.Job)
func (*SystemStack) SetNodes ¶ added in v0.2.0
func (s *SystemStack) SetNodes(baseNodes []*structs.Node)