mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 18:35:44 +03:00
scheduler: thread size through
This commit is contained in:
@@ -189,7 +189,7 @@ func (s *ServiceScheduler) computePlacements(job *structs.Job, place []allocTupl
|
||||
NodeID: option.Node.ID,
|
||||
JobID: job.ID,
|
||||
Job: job,
|
||||
Resources: nil, // TODO: size
|
||||
Resources: stack.TaskGroupSize(),
|
||||
Metrics: ctx.Metrics(),
|
||||
Status: structs.AllocStatusPending,
|
||||
}
|
||||
|
||||
@@ -15,6 +15,10 @@ type Stack interface {
|
||||
// This must be called in between calls to Select.
|
||||
SetTaskGroup(tg *structs.TaskGroup)
|
||||
|
||||
// TaskGroupSize returns the size of the task group.
|
||||
// This is only valid after calling SetTaskGroup
|
||||
TaskGroupSize() *structs.Resources
|
||||
|
||||
// Select is used to select a node for the task group
|
||||
Select() *RankedNode
|
||||
}
|
||||
@@ -34,6 +38,8 @@ type ServiceStack struct {
|
||||
BinPack *BinPackIterator
|
||||
Limit *LimitIterator
|
||||
MaxScore *MaxScoreIterator
|
||||
|
||||
size *structs.Resources
|
||||
}
|
||||
|
||||
// NewServiceStack constructs a stack used for selecting service placements
|
||||
@@ -99,6 +105,9 @@ func (s *ServiceStack) SetTaskGroup(tg *structs.TaskGroup) {
|
||||
size.Add(task.Resources)
|
||||
}
|
||||
|
||||
// Store the size
|
||||
s.size = size
|
||||
|
||||
// Update the parameters of iterators
|
||||
s.TaskGroupDrivers.SetDrivers(drivers)
|
||||
s.TaskGroupConstraint.SetConstraints(constr)
|
||||
@@ -108,6 +117,10 @@ func (s *ServiceStack) SetTaskGroup(tg *structs.TaskGroup) {
|
||||
s.MaxScore.Reset()
|
||||
}
|
||||
|
||||
func (s *ServiceStack) TaskGroupSize() *structs.Resources {
|
||||
return s.size
|
||||
}
|
||||
|
||||
func (s *ServiceStack) Select() *RankedNode {
|
||||
return s.MaxScore.Next()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user