Skip to content

Commit b052322

Browse files
Merge d2e3a9d into backport/NMD-396-set-status/readily-deep-goblin
2 parents 129b6d9 + d2e3a9d commit b052322

5 files changed

Lines changed: 17 additions & 28 deletions

File tree

scheduler/generic_sched.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func (s *GenericScheduler) Process(eval *structs.Evaluation) (err error) {
129129
default:
130130
desc := fmt.Sprintf("scheduler cannot handle '%s' evaluation reason",
131131
eval.TriggeredBy)
132-
return setStatus(s.logger, s.planner, s.eval, nil, s.blocked,
132+
return setStatus(s.logger, s.planner, s.eval, s.blocked,
133133
s.failedTGAllocs, s.planAnnotations, structs.EvalStatusFailed, desc, s.queuedAllocs,
134134
s.deployment.GetID())
135135
}
@@ -148,7 +148,7 @@ func (s *GenericScheduler) Process(eval *structs.Evaluation) (err error) {
148148
if err := s.createBlockedEval(true); err != nil {
149149
mErr.Errors = append(mErr.Errors, err)
150150
}
151-
if err := setStatus(s.logger, s.planner, s.eval, nil, s.blocked,
151+
if err := setStatus(s.logger, s.planner, s.eval, s.blocked,
152152
s.failedTGAllocs, s.planAnnotations, statusErr.EvalStatus, err.Error(),
153153
s.queuedAllocs, s.deployment.GetID()); err != nil {
154154
mErr.Errors = append(mErr.Errors, err)
@@ -170,7 +170,7 @@ func (s *GenericScheduler) Process(eval *structs.Evaluation) (err error) {
170170
}
171171

172172
// Update the status to complete
173-
return setStatus(s.logger, s.planner, s.eval, nil, s.blocked,
173+
return setStatus(s.logger, s.planner, s.eval, s.blocked,
174174
s.failedTGAllocs, s.planAnnotations, structs.EvalStatusComplete, "", s.queuedAllocs,
175175
s.deployment.GetID())
176176
}

scheduler/scheduler_sysbatch.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func (s *SysBatchScheduler) Process(eval *structs.Evaluation) (err error) {
7878
// Verify the evaluation trigger reason is understood
7979
if !s.canHandle(eval.TriggeredBy) {
8080
desc := fmt.Sprintf("scheduler cannot handle '%s' evaluation reason", eval.TriggeredBy)
81-
return setStatus(s.logger, s.planner, s.eval, nil, nil,
81+
return setStatus(s.logger, s.planner, s.eval, nil,
8282
s.failedTGAllocs, s.planAnnotations, structs.EvalStatusFailed, desc,
8383
s.queuedAllocs, "")
8484
}
@@ -89,15 +89,15 @@ func (s *SysBatchScheduler) Process(eval *structs.Evaluation) (err error) {
8989
progress := func() bool { return progressMade(s.planResult) }
9090
if err := retryMax(limit, s.process, progress); err != nil {
9191
if statusErr, ok := err.(*SetStatusError); ok {
92-
return setStatus(s.logger, s.planner, s.eval, nil, nil,
92+
return setStatus(s.logger, s.planner, s.eval, nil,
9393
s.failedTGAllocs, s.planAnnotations, statusErr.EvalStatus, err.Error(),
9494
s.queuedAllocs, "")
9595
}
9696
return err
9797
}
9898

9999
// Update the status to complete
100-
return setStatus(s.logger, s.planner, s.eval, nil, nil,
100+
return setStatus(s.logger, s.planner, s.eval, nil,
101101
s.failedTGAllocs, s.planAnnotations, structs.EvalStatusComplete, "",
102102
s.queuedAllocs, "")
103103
}

scheduler/scheduler_system.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func (s *SystemScheduler) Process(eval *structs.Evaluation) (err error) {
8787
// Verify the evaluation trigger reason is understood
8888
if !s.canHandle(eval.TriggeredBy) {
8989
desc := fmt.Sprintf("scheduler cannot handle '%s' evaluation reason", eval.TriggeredBy)
90-
return setStatus(s.logger, s.planner, s.eval, nil, nil,
90+
return setStatus(s.logger, s.planner, s.eval, nil,
9191
s.failedTGAllocs, s.planAnnotations, structs.EvalStatusFailed, desc,
9292
s.queuedAllocs, s.deployment.GetID())
9393
}
@@ -98,15 +98,15 @@ func (s *SystemScheduler) Process(eval *structs.Evaluation) (err error) {
9898
progress := func() bool { return progressMade(s.planResult) }
9999
if err := retryMax(limit, s.process, progress); err != nil {
100100
if statusErr, ok := err.(*SetStatusError); ok {
101-
return setStatus(s.logger, s.planner, s.eval, nil, nil,
101+
return setStatus(s.logger, s.planner, s.eval, nil,
102102
s.failedTGAllocs, s.planAnnotations, statusErr.EvalStatus, err.Error(),
103103
s.queuedAllocs, s.deployment.GetID())
104104
}
105105
return err
106106
}
107107

108108
// Update the status to complete
109-
return setStatus(s.logger, s.planner, s.eval, nil, nil,
109+
return setStatus(s.logger, s.planner, s.eval, nil,
110110
s.failedTGAllocs, s.planAnnotations, structs.EvalStatusComplete, "",
111111
s.queuedAllocs, s.deployment.GetID())
112112
}

scheduler/util.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ func renderTemplatesUpdated(a, b *structs.RestartPolicy, msg string) comparison
542542

543543
// setStatus is used to update the status of the evaluation
544544
func setStatus(logger log.Logger, planner sstructs.Planner,
545-
eval, nextEval, spawnedBlocked *structs.Evaluation,
545+
eval, spawnedBlocked *structs.Evaluation,
546546
tgMetrics map[string]*structs.AllocMetric,
547547
annotations *structs.PlanAnnotations,
548548
status, desc string,
@@ -554,9 +554,7 @@ func setStatus(logger log.Logger, planner sstructs.Planner,
554554
newEval.StatusDescription = desc
555555
newEval.DeploymentID = deploymentID
556556
newEval.FailedTGAllocs = tgMetrics
557-
if nextEval != nil {
558-
newEval.NextEval = nextEval.ID
559-
}
557+
560558
if spawnedBlocked != nil {
561559
newEval.BlockedEval = spawnedBlocked.ID
562560
}

scheduler/util_test.go

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -613,26 +613,17 @@ func TestSetStatus(t *testing.T) {
613613
eval := mock.Eval()
614614
status := "a"
615615
desc := "b"
616-
must.NoError(t, setStatus(logger, h, eval, nil, nil, nil, nil, status, desc, nil, ""))
616+
must.NoError(t, setStatus(logger, h, eval, nil, nil, nil, status, desc, nil, ""))
617617
must.Eq(t, 1, len(h.Evals), must.Sprintf("setStatus() didn't update plan: %v", h.Evals))
618618

619619
newEval := h.Evals[0]
620620
must.True(t, newEval.ID == eval.ID && newEval.Status == status && newEval.StatusDescription == desc,
621621
must.Sprintf("setStatus() submited invalid eval: %v", newEval))
622622

623-
// Test next evals
624-
h = tests.NewHarness(t)
625-
next := mock.Eval()
626-
must.NoError(t, setStatus(logger, h, eval, next, nil, nil, nil, status, desc, nil, ""))
627-
must.Eq(t, 1, len(h.Evals), must.Sprintf("setStatus() didn't update plan: %v", h.Evals))
628-
629-
newEval = h.Evals[0]
630-
must.Eq(t, next.ID, newEval.NextEval, must.Sprintf("setStatus() didn't set nextEval correctly: %v", newEval))
631-
632623
// Test blocked evals
633624
h = tests.NewHarness(t)
634625
blocked := mock.Eval()
635-
must.NoError(t, setStatus(logger, h, eval, nil, blocked, nil, nil, status, desc, nil, ""))
626+
must.NoError(t, setStatus(logger, h, eval, blocked, nil, nil, status, desc, nil, ""))
636627
must.Eq(t, 1, len(h.Evals), must.Sprintf("setStatus() didn't update plan: %v", h.Evals))
637628

638629
newEval = h.Evals[0]
@@ -641,7 +632,7 @@ func TestSetStatus(t *testing.T) {
641632
// Test metrics
642633
h = tests.NewHarness(t)
643634
metrics := map[string]*structs.AllocMetric{"foo": nil}
644-
must.NoError(t, setStatus(logger, h, eval, nil, nil, metrics, nil, status, desc, nil, ""))
635+
must.NoError(t, setStatus(logger, h, eval, nil, metrics, nil, status, desc, nil, ""))
645636
must.Eq(t, 1, len(h.Evals), must.Sprintf("setStatus() didn't update plan: %v", h.Evals))
646637

647638
newEval = h.Evals[0]
@@ -652,7 +643,7 @@ func TestSetStatus(t *testing.T) {
652643
h = tests.NewHarness(t)
653644
queuedAllocs := map[string]int{"web": 1}
654645

655-
must.NoError(t, setStatus(logger, h, eval, nil, nil, metrics, nil, status, desc, queuedAllocs, ""))
646+
must.NoError(t, setStatus(logger, h, eval, nil, metrics, nil, status, desc, queuedAllocs, ""))
656647
must.Eq(t, 1, len(h.Evals), must.Sprintf("setStatus() didn't update plan: %v", h.Evals))
657648

658649
// Test annotations
@@ -662,15 +653,15 @@ func TestSetStatus(t *testing.T) {
662653
PreemptedAllocs: []*structs.AllocListStub{{ID: uuid.Generate()}},
663654
}
664655

665-
must.NoError(t, setStatus(logger, h, eval, nil, nil, metrics, annotations, status, desc, queuedAllocs, ""))
656+
must.NoError(t, setStatus(logger, h, eval, nil, metrics, annotations, status, desc, queuedAllocs, ""))
666657
must.Eq(t, 1, len(h.Evals), must.Sprintf("setStatus() didn't update plan: %v", h.Evals))
667658

668659
newEval = h.Evals[0]
669660
must.Eq(t, annotations, newEval.PlanAnnotations, must.Sprintf("setStatus() didn't set plan annotations correctly: %v", newEval))
670661

671662
h = tests.NewHarness(t)
672663
dID := uuid.Generate()
673-
must.NoError(t, setStatus(logger, h, eval, nil, nil, metrics, nil, status, desc, queuedAllocs, dID))
664+
must.NoError(t, setStatus(logger, h, eval, nil, metrics, nil, status, desc, queuedAllocs, dID))
674665
must.Eq(t, 1, len(h.Evals), must.Sprintf("setStatus() didn't update plan: %v", h.Evals))
675666

676667
newEval = h.Evals[0]

0 commit comments

Comments
 (0)