diff --git a/scheduler/generic_sched.go b/scheduler/generic_sched.go index e55e78dc6..6649c2337 100644 --- a/scheduler/generic_sched.go +++ b/scheduler/generic_sched.go @@ -105,7 +105,7 @@ func (s *GenericScheduler) Process(eval *structs.Evaluation) error { switch eval.TriggeredBy { case structs.EvalTriggerJobRegister, structs.EvalTriggerNodeUpdate, structs.EvalTriggerJobDeregister, structs.EvalTriggerRollingUpdate, - structs.EvalTriggerPeriodicJob: + structs.EvalTriggerPeriodicJob, structs.EvalTriggerMaxPlans: default: desc := fmt.Sprintf("scheduler cannot handle '%s' evaluation reason", eval.TriggeredBy) diff --git a/scheduler/generic_sched_test.go b/scheduler/generic_sched_test.go index 4b9f9f402..7798a6f84 100644 --- a/scheduler/generic_sched_test.go +++ b/scheduler/generic_sched_test.go @@ -454,11 +454,47 @@ func TestServiceSched_JobRegister_FeasibleAndInfeasibleTG(t *testing.T) { h.AssertEvalStatus(t, structs.EvalStatusComplete) } -func TestServiceSched_EvaluateBlockedEval(t *testing.T) { +// This test just ensures the scheduler handles the eval type to avoid +// regressions. +func TestServiceSched_EvaluateMaxPlanEval(t *testing.T) { h := NewHarness(t) // Create a job and set the task group count to zero. job := mock.Job() + job.TaskGroups[0].Count = 0 + noErr(t, h.State.UpsertJob(h.NextIndex(), job)) + + // Create a mock blocked evaluation + eval := &structs.Evaluation{ + ID: structs.GenerateUUID(), + Status: structs.EvalStatusBlocked, + Priority: job.Priority, + TriggeredBy: structs.EvalTriggerMaxPlans, + JobID: job.ID, + } + + // Insert it into the state store + noErr(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + + // Process the evaluation + err := h.Process(NewServiceScheduler, eval) + if err != nil { + t.Fatalf("err: %v", err) + } + + // Ensure there was no plan + if len(h.Plans) != 0 { + t.Fatalf("bad: %#v", h.Plans) + } + + h.AssertEvalStatus(t, structs.EvalStatusComplete) +} + +func TestServiceSched_EvaluateBlockedEval(t *testing.T) { + h := NewHarness(t) + + // Create a job + job := mock.Job() noErr(t, h.State.UpsertJob(h.NextIndex(), job)) // Create a mock blocked evaluation