Commit 92bddbc3 authored by Alex Dadgar's avatar Alex Dadgar
Browse files

rename SpawnedBlockedEval and simplify map safety check

parent 9f5ab664
Showing with 35 additions and 37 deletions
+35 -37
......@@ -54,23 +54,23 @@ func (e *Evaluations) Allocations(evalID string, q *QueryOptions) ([]*Allocation
// Evaluation is used to serialize an evaluation.
type Evaluation struct {
ID string
Priority int
Type string
TriggeredBy string
JobID string
JobModifyIndex uint64
NodeID string
NodeModifyIndex uint64
Status string
StatusDescription string
Wait time.Duration
NextEval string
PreviousEval string
SpawnedBlockedEval string
FailedTGAllocs map[string]*AllocationMetric
CreateIndex uint64
ModifyIndex uint64
ID string
Priority int
Type string
TriggeredBy string
JobID string
JobModifyIndex uint64
NodeID string
NodeModifyIndex uint64
Status string
StatusDescription string
Wait time.Duration
NextEval string
PreviousEval string
BlockedEval string
FailedTGAllocs map[string]*AllocationMetric
CreateIndex uint64
ModifyIndex uint64
}
// EvalIndexSort is a wrapper to sort evaluations by CreateIndex.
......
......@@ -307,9 +307,9 @@ func (m *monitor) monitor(evalID string, allowPrefix bool) int {
dumpAllocMetrics(m.ui, metrics, false)
}
if eval.SpawnedBlockedEval != "" {
m.ui.Output(fmt.Sprintf("Spawned follow up blocked evaluation %q to place remainder",
limit(eval.SpawnedBlockedEval, m.length)))
if eval.BlockedEval != "" {
m.ui.Output(fmt.Sprintf("Evaluation %q waiting for additional capacity to place remainder",
limit(eval.BlockedEval, m.length)))
}
}
default:
......
......@@ -2617,10 +2617,10 @@ type Evaluation struct {
// This is used to support rolling upgrades, where we need a chain of evaluations.
PreviousEval string
// SpawnedBlockedEval is the evaluation ID for a created blocked eval. A
// BlockedEval is the evaluation ID for a created blocked eval. A
// blocked eval will be created if all allocations could not be placed due
// to constraints or lacking resources.
SpawnedBlockedEval string
BlockedEval string
// FailedTGAllocs are task groups which have allocations that could not be
// made, but the metrics are persisted so that the user can use the feedback
......@@ -2744,10 +2744,10 @@ func (e *Evaluation) NextRollingEval(wait time.Duration) *Evaluation {
}
}
// BlockedEval creates a blocked evaluation to followup this eval to place any
// CreateBlockedEval creates a blocked evaluation to followup this eval to place any
// failed allocations. It takes the classes marked explicitly eligible or
// ineligible and whether the job has escaped computed node classes.
func (e *Evaluation) BlockedEval(classEligibility map[string]bool, escaped bool) *Evaluation {
func (e *Evaluation) CreateBlockedEval(classEligibility map[string]bool, escaped bool) *Evaluation {
return &Evaluation{
ID: GenerateUUID(),
Priority: e.Priority,
......
......@@ -140,7 +140,7 @@ func (s *GenericScheduler) createBlockedEval() error {
classEligibility = e.GetClasses()
}
s.blocked = s.eval.BlockedEval(classEligibility, escaped)
s.blocked = s.eval.CreateBlockedEval(classEligibility, escaped)
return s.planner.CreateEval(s.blocked)
}
......@@ -370,11 +370,9 @@ func (s *GenericScheduler) computePlacements(place []allocTuple) error {
for _, missing := range place {
// Check if this task group has already failed
if s.eval.FailedTGAllocs != nil {
if metric, ok := s.eval.FailedTGAllocs[missing.TaskGroup.Name]; ok {
metric.CoalescedFailures += 1
continue
}
if metric, ok := s.eval.FailedTGAllocs[missing.TaskGroup.Name]; ok {
metric.CoalescedFailures += 1
continue
}
// Attempt to match the task group
......
......@@ -51,7 +51,7 @@ func TestServiceSched_JobRegister(t *testing.T) {
// Ensure the eval has no spawned blocked eval
if len(h.Evals) != 1 {
t.Fatalf("bad: %#v", h.Evals)
if h.Evals[0].SpawnedBlockedEval != "" {
if h.Evals[0].BlockedEval != "" {
t.Fatalf("bad: %#v", h.Evals[0])
}
}
......@@ -248,7 +248,7 @@ func TestServiceSched_JobRegister_AllocFail(t *testing.T) {
outEval := h.Evals[0]
// Ensure the eval has its spawned blocked eval
if outEval.SpawnedBlockedEval != h.CreateEvals[0].ID {
if outEval.BlockedEval != h.CreateEvals[0].ID {
t.Fatalf("bad: %#v", outEval)
}
......@@ -432,7 +432,7 @@ func TestServiceSched_JobRegister_FeasibleAndInfeasibleTG(t *testing.T) {
outEval := h.Evals[0]
// Ensure the eval has its spawned blocked eval
if outEval.SpawnedBlockedEval != h.CreateEvals[0].ID {
if outEval.BlockedEval != h.CreateEvals[0].ID {
t.Fatalf("bad: %#v", outEval)
}
......
......@@ -237,7 +237,7 @@ func (s *SystemScheduler) computePlacements(place []allocTuple) error {
// Attempt to match the task group
option, _ := s.stack.Select(missing.TaskGroup)
if option == nil && s.eval.FailedTGAllocs != nil {
if option == nil {
// Check if this task group has already failed
if metric, ok := s.eval.FailedTGAllocs[missing.TaskGroup.Name]; ok {
metric.CoalescedFailures += 1
......
......@@ -365,7 +365,7 @@ func setStatus(logger *log.Logger, planner Planner, eval, nextEval, spawnedBlock
newEval.NextEval = nextEval.ID
}
if spawnedBlocked != nil {
newEval.SpawnedBlockedEval = spawnedBlocked.ID
newEval.BlockedEval = spawnedBlocked.ID
}
return planner.UpdateEval(newEval)
}
......
......@@ -526,8 +526,8 @@ func TestSetStatus(t *testing.T) {
}
newEval = h.Evals[0]
if newEval.SpawnedBlockedEval != blocked.ID {
t.Fatalf("setStatus() didn't set SpawnedBlockedEval correctly: %v", newEval)
if newEval.BlockedEval != blocked.ID {
t.Fatalf("setStatus() didn't set BlockedEval correctly: %v", newEval)
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment