diff --git a/client/alloc_runner.go b/client/alloc_runner.go index 6ee83a098359..8aca846992c2 100644 --- a/client/alloc_runner.go +++ b/client/alloc_runner.go @@ -262,7 +262,7 @@ func (r *AllocRunner) Alloc() *structs.Allocation { } else if pending { alloc.ClientStatus = structs.AllocClientStatusPending } else if dead { - alloc.ClientStatus = structs.AllocClientStatusDead + alloc.ClientStatus = structs.AllocClientStatusComplete } return alloc diff --git a/client/alloc_runner_test.go b/client/alloc_runner_test.go index 5d31e97e9f61..3893d0b7b80e 100644 --- a/client/alloc_runner_test.go +++ b/client/alloc_runner_test.go @@ -51,8 +51,8 @@ func TestAllocRunner_SimpleRun(t *testing.T) { return false, fmt.Errorf("No updates") } last := upd.Allocs[upd.Count-1] - if last.ClientStatus != structs.AllocClientStatusDead { - return false, fmt.Errorf("got status %v; want %v", last.ClientStatus, structs.AllocClientStatusDead) + if last.ClientStatus != structs.AllocClientStatusComplete { + return false, fmt.Errorf("got status %v; want %v", last.ClientStatus, structs.AllocClientStatusComplete) } return true, nil }, func(err error) { @@ -96,8 +96,8 @@ func TestAllocRunner_TerminalUpdate_Destroy(t *testing.T) { // Check the status has changed. last := upd.Allocs[upd.Count-1] - if last.ClientStatus != structs.AllocClientStatusDead { - return false, fmt.Errorf("got client status %v; want %v", last.ClientStatus, structs.AllocClientStatusDead) + if last.ClientStatus != structs.AllocClientStatusComplete { + return false, fmt.Errorf("got client status %v; want %v", last.ClientStatus, structs.AllocClientStatusComplete) } // Check the state still exists @@ -125,8 +125,8 @@ func TestAllocRunner_TerminalUpdate_Destroy(t *testing.T) { // Check the status has changed. last := upd.Allocs[upd.Count-1] - if last.ClientStatus != structs.AllocClientStatusDead { - return false, fmt.Errorf("got client status %v; want %v", last.ClientStatus, structs.AllocClientStatusDead) + if last.ClientStatus != structs.AllocClientStatusComplete { + return false, fmt.Errorf("got client status %v; want %v", last.ClientStatus, structs.AllocClientStatusComplete) } // Check the state was cleaned @@ -173,8 +173,8 @@ func TestAllocRunner_Destroy(t *testing.T) { // Check the status has changed. last := upd.Allocs[upd.Count-1] - if last.ClientStatus != structs.AllocClientStatusDead { - return false, fmt.Errorf("got client status %v; want %v", last.ClientStatus, structs.AllocClientStatusDead) + if last.ClientStatus != structs.AllocClientStatusComplete { + return false, fmt.Errorf("got client status %v; want %v", last.ClientStatus, structs.AllocClientStatusComplete) } // Check the state was cleaned @@ -357,8 +357,8 @@ func TestAllocRunner_SaveRestoreState_TerminalAlloc(t *testing.T) { // Check the status has changed. last := upd.Allocs[upd.Count-1] - if last.ClientStatus != structs.AllocClientStatusDead { - return false, fmt.Errorf("got client status %v; want %v", last.ClientStatus, structs.AllocClientStatusDead) + if last.ClientStatus != structs.AllocClientStatusComplete { + return false, fmt.Errorf("got client status %v; want %v", last.ClientStatus, structs.AllocClientStatusComplete) } // Check the state was cleaned diff --git a/nomad/fsm.go b/nomad/fsm.go index 5516b764f333..7f9c6e08b3f0 100644 --- a/nomad/fsm.go +++ b/nomad/fsm.go @@ -407,7 +407,7 @@ func (n *nomadFSM) applyAllocClientUpdate(buf []byte, index uint64) interface{} // Unblock evals for the nodes computed node class if the client has // finished running an allocation. for _, alloc := range req.Alloc { - if alloc.ClientStatus == structs.AllocClientStatusDead || + if alloc.ClientStatus == structs.AllocClientStatusComplete || alloc.ClientStatus == structs.AllocClientStatusFailed { nodeID := alloc.NodeID node, err := n.state.NodeByID(nodeID) diff --git a/nomad/fsm_test.go b/nomad/fsm_test.go index f6a7bc5e7a07..0e73fabd997e 100644 --- a/nomad/fsm_test.go +++ b/nomad/fsm_test.go @@ -651,7 +651,7 @@ func TestFSM_UpdateAllocFromClient_Unblock(t *testing.T) { clientAlloc := new(structs.Allocation) *clientAlloc = *alloc - clientAlloc.ClientStatus = structs.AllocClientStatusDead + clientAlloc.ClientStatus = structs.AllocClientStatusComplete update2 := &structs.Allocation{ ID: alloc2.ID, ClientStatus: structs.AllocClientStatusRunning, diff --git a/nomad/structs/funcs_test.go b/nomad/structs/funcs_test.go index 93ce5cb308b7..cc0d574d68d7 100644 --- a/nomad/structs/funcs_test.go +++ b/nomad/structs/funcs_test.go @@ -34,7 +34,7 @@ func TestFilterTerminalAllocs(t *testing.T) { &Allocation{ ID: "bam", DesiredStatus: AllocDesiredStatusRun, - ClientStatus: AllocClientStatusDead, + ClientStatus: AllocClientStatusComplete, }, } diff --git a/nomad/structs/structs.go b/nomad/structs/structs.go index c92841a9505b..aff29208a36b 100644 --- a/nomad/structs/structs.go +++ b/nomad/structs/structs.go @@ -2085,10 +2085,10 @@ const ( ) const ( - AllocClientStatusPending = "pending" - AllocClientStatusRunning = "running" - AllocClientStatusDead = "dead" - AllocClientStatusFailed = "failed" + AllocClientStatusPending = "pending" + AllocClientStatusRunning = "running" + AllocClientStatusComplete = "complete" + AllocClientStatusFailed = "failed" ) // Allocation is used to allocate the placement of a task group to a node. @@ -2206,7 +2206,7 @@ func (a *Allocation) TerminalStatus() bool { } switch a.ClientStatus { - case AllocClientStatusDead, AllocClientStatusFailed: + case AllocClientStatusComplete, AllocClientStatusFailed: return true default: return false diff --git a/scheduler/generic_sched_test.go b/scheduler/generic_sched_test.go index d5137947ca72..14925600d2b0 100644 --- a/scheduler/generic_sched_test.go +++ b/scheduler/generic_sched_test.go @@ -1097,7 +1097,7 @@ func TestBatchSched_Run_DeadAlloc(t *testing.T) { alloc.JobID = job.ID alloc.NodeID = node.ID alloc.Name = "my-job.web[0]" - alloc.ClientStatus = structs.AllocClientStatusDead + alloc.ClientStatus = structs.AllocClientStatusComplete noErr(t, h.State.UpsertAllocs(h.NextIndex(), []*structs.Allocation{alloc})) // Create a mock evaluation to register the job