From 6a21f9fe964408b97c271076030403b8ddf72ecb Mon Sep 17 00:00:00 2001 From: Alex Dadgar Date: Mon, 24 Sep 2018 14:47:49 -0700 Subject: [PATCH] Unique TriggerBy for blocked evals Give blocked evals a unique triggerby reason to make debugging a chain of evaluations easier. --- nomad/structs/structs.go | 3 ++- scheduler/generic_sched.go | 2 +- scheduler/generic_sched_test.go | 4 ++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/nomad/structs/structs.go b/nomad/structs/structs.go index d4ea11036..e4980edd2 100644 --- a/nomad/structs/structs.go +++ b/nomad/structs/structs.go @@ -6751,6 +6751,7 @@ const ( EvalTriggerFailedFollowUp = "failed-follow-up" EvalTriggerMaxPlans = "max-plan-attempts" EvalTriggerRetryFailedAlloc = "alloc-failure" + EvalTriggerQueuedAllocs = "queued-allocs" ) const ( @@ -7016,7 +7017,7 @@ func (e *Evaluation) CreateBlockedEval(classEligibility map[string]bool, Namespace: e.Namespace, Priority: e.Priority, Type: e.Type, - TriggeredBy: e.TriggeredBy, + TriggeredBy: EvalTriggerQueuedAllocs, JobID: e.JobID, JobModifyIndex: e.JobModifyIndex, Status: EvalStatusBlocked, diff --git a/scheduler/generic_sched.go b/scheduler/generic_sched.go index eb2b8023f..ec9a31533 100644 --- a/scheduler/generic_sched.go +++ b/scheduler/generic_sched.go @@ -128,7 +128,7 @@ func (s *GenericScheduler) Process(eval *structs.Evaluation) error { switch eval.TriggeredBy { case structs.EvalTriggerJobRegister, structs.EvalTriggerJobDeregister, structs.EvalTriggerNodeDrain, structs.EvalTriggerNodeUpdate, - structs.EvalTriggerRollingUpdate, + structs.EvalTriggerRollingUpdate, structs.EvalTriggerQueuedAllocs, structs.EvalTriggerPeriodicJob, structs.EvalTriggerMaxPlans, structs.EvalTriggerDeploymentWatcher, structs.EvalTriggerRetryFailedAlloc: default: diff --git a/scheduler/generic_sched_test.go b/scheduler/generic_sched_test.go index d735c2489..b20f43237 100644 --- a/scheduler/generic_sched_test.go +++ b/scheduler/generic_sched_test.go @@ -241,6 +241,10 @@ func TestServiceSched_JobRegister_DiskConstraints(t *testing.T) { t.Fatalf("bad: %#v", h.CreateEvals) } + if h.CreateEvals[0].TriggeredBy != structs.EvalTriggerQueuedAllocs { + t.Fatalf("bad: %#v", h.CreateEvals[0]) + } + // Ensure the plan allocated only one allocation var planned []*structs.Allocation for _, allocList := range plan.NodeAllocation {