Successful allocations are marked as complete instead of dead
This commit is contained in:
parent
a2775c34d0
commit
94522e7bed
|
@ -262,7 +262,7 @@ func (r *AllocRunner) Alloc() *structs.Allocation {
|
||||||
} else if pending {
|
} else if pending {
|
||||||
alloc.ClientStatus = structs.AllocClientStatusPending
|
alloc.ClientStatus = structs.AllocClientStatusPending
|
||||||
} else if dead {
|
} else if dead {
|
||||||
alloc.ClientStatus = structs.AllocClientStatusDead
|
alloc.ClientStatus = structs.AllocClientStatusComplete
|
||||||
}
|
}
|
||||||
|
|
||||||
return alloc
|
return alloc
|
||||||
|
|
|
@ -51,8 +51,8 @@ func TestAllocRunner_SimpleRun(t *testing.T) {
|
||||||
return false, fmt.Errorf("No updates")
|
return false, fmt.Errorf("No updates")
|
||||||
}
|
}
|
||||||
last := upd.Allocs[upd.Count-1]
|
last := upd.Allocs[upd.Count-1]
|
||||||
if last.ClientStatus != structs.AllocClientStatusDead {
|
if last.ClientStatus != structs.AllocClientStatusComplete {
|
||||||
return false, fmt.Errorf("got status %v; want %v", last.ClientStatus, structs.AllocClientStatusDead)
|
return false, fmt.Errorf("got status %v; want %v", last.ClientStatus, structs.AllocClientStatusComplete)
|
||||||
}
|
}
|
||||||
return true, nil
|
return true, nil
|
||||||
}, func(err error) {
|
}, func(err error) {
|
||||||
|
@ -96,8 +96,8 @@ func TestAllocRunner_TerminalUpdate_Destroy(t *testing.T) {
|
||||||
|
|
||||||
// Check the status has changed.
|
// Check the status has changed.
|
||||||
last := upd.Allocs[upd.Count-1]
|
last := upd.Allocs[upd.Count-1]
|
||||||
if last.ClientStatus != structs.AllocClientStatusDead {
|
if last.ClientStatus != structs.AllocClientStatusComplete {
|
||||||
return false, fmt.Errorf("got client status %v; want %v", last.ClientStatus, structs.AllocClientStatusDead)
|
return false, fmt.Errorf("got client status %v; want %v", last.ClientStatus, structs.AllocClientStatusComplete)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the state still exists
|
// Check the state still exists
|
||||||
|
@ -125,8 +125,8 @@ func TestAllocRunner_TerminalUpdate_Destroy(t *testing.T) {
|
||||||
|
|
||||||
// Check the status has changed.
|
// Check the status has changed.
|
||||||
last := upd.Allocs[upd.Count-1]
|
last := upd.Allocs[upd.Count-1]
|
||||||
if last.ClientStatus != structs.AllocClientStatusDead {
|
if last.ClientStatus != structs.AllocClientStatusComplete {
|
||||||
return false, fmt.Errorf("got client status %v; want %v", last.ClientStatus, structs.AllocClientStatusDead)
|
return false, fmt.Errorf("got client status %v; want %v", last.ClientStatus, structs.AllocClientStatusComplete)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the state was cleaned
|
// Check the state was cleaned
|
||||||
|
@ -173,8 +173,8 @@ func TestAllocRunner_Destroy(t *testing.T) {
|
||||||
|
|
||||||
// Check the status has changed.
|
// Check the status has changed.
|
||||||
last := upd.Allocs[upd.Count-1]
|
last := upd.Allocs[upd.Count-1]
|
||||||
if last.ClientStatus != structs.AllocClientStatusDead {
|
if last.ClientStatus != structs.AllocClientStatusComplete {
|
||||||
return false, fmt.Errorf("got client status %v; want %v", last.ClientStatus, structs.AllocClientStatusDead)
|
return false, fmt.Errorf("got client status %v; want %v", last.ClientStatus, structs.AllocClientStatusComplete)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the state was cleaned
|
// Check the state was cleaned
|
||||||
|
@ -357,8 +357,8 @@ func TestAllocRunner_SaveRestoreState_TerminalAlloc(t *testing.T) {
|
||||||
|
|
||||||
// Check the status has changed.
|
// Check the status has changed.
|
||||||
last := upd.Allocs[upd.Count-1]
|
last := upd.Allocs[upd.Count-1]
|
||||||
if last.ClientStatus != structs.AllocClientStatusDead {
|
if last.ClientStatus != structs.AllocClientStatusComplete {
|
||||||
return false, fmt.Errorf("got client status %v; want %v", last.ClientStatus, structs.AllocClientStatusDead)
|
return false, fmt.Errorf("got client status %v; want %v", last.ClientStatus, structs.AllocClientStatusComplete)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the state was cleaned
|
// Check the state was cleaned
|
||||||
|
|
|
@ -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
|
// Unblock evals for the nodes computed node class if the client has
|
||||||
// finished running an allocation.
|
// finished running an allocation.
|
||||||
for _, alloc := range req.Alloc {
|
for _, alloc := range req.Alloc {
|
||||||
if alloc.ClientStatus == structs.AllocClientStatusDead ||
|
if alloc.ClientStatus == structs.AllocClientStatusComplete ||
|
||||||
alloc.ClientStatus == structs.AllocClientStatusFailed {
|
alloc.ClientStatus == structs.AllocClientStatusFailed {
|
||||||
nodeID := alloc.NodeID
|
nodeID := alloc.NodeID
|
||||||
node, err := n.state.NodeByID(nodeID)
|
node, err := n.state.NodeByID(nodeID)
|
||||||
|
|
|
@ -651,7 +651,7 @@ func TestFSM_UpdateAllocFromClient_Unblock(t *testing.T) {
|
||||||
|
|
||||||
clientAlloc := new(structs.Allocation)
|
clientAlloc := new(structs.Allocation)
|
||||||
*clientAlloc = *alloc
|
*clientAlloc = *alloc
|
||||||
clientAlloc.ClientStatus = structs.AllocClientStatusDead
|
clientAlloc.ClientStatus = structs.AllocClientStatusComplete
|
||||||
update2 := &structs.Allocation{
|
update2 := &structs.Allocation{
|
||||||
ID: alloc2.ID,
|
ID: alloc2.ID,
|
||||||
ClientStatus: structs.AllocClientStatusRunning,
|
ClientStatus: structs.AllocClientStatusRunning,
|
||||||
|
|
|
@ -34,7 +34,7 @@ func TestFilterTerminalAllocs(t *testing.T) {
|
||||||
&Allocation{
|
&Allocation{
|
||||||
ID: "bam",
|
ID: "bam",
|
||||||
DesiredStatus: AllocDesiredStatusRun,
|
DesiredStatus: AllocDesiredStatusRun,
|
||||||
ClientStatus: AllocClientStatusDead,
|
ClientStatus: AllocClientStatusComplete,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2087,7 +2087,7 @@ const (
|
||||||
const (
|
const (
|
||||||
AllocClientStatusPending = "pending"
|
AllocClientStatusPending = "pending"
|
||||||
AllocClientStatusRunning = "running"
|
AllocClientStatusRunning = "running"
|
||||||
AllocClientStatusDead = "dead"
|
AllocClientStatusComplete = "complete"
|
||||||
AllocClientStatusFailed = "failed"
|
AllocClientStatusFailed = "failed"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -2206,7 +2206,7 @@ func (a *Allocation) TerminalStatus() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
switch a.ClientStatus {
|
switch a.ClientStatus {
|
||||||
case AllocClientStatusDead, AllocClientStatusFailed:
|
case AllocClientStatusComplete, AllocClientStatusFailed:
|
||||||
return true
|
return true
|
||||||
default:
|
default:
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -1097,7 +1097,7 @@ func TestBatchSched_Run_DeadAlloc(t *testing.T) {
|
||||||
alloc.JobID = job.ID
|
alloc.JobID = job.ID
|
||||||
alloc.NodeID = node.ID
|
alloc.NodeID = node.ID
|
||||||
alloc.Name = "my-job.web[0]"
|
alloc.Name = "my-job.web[0]"
|
||||||
alloc.ClientStatus = structs.AllocClientStatusDead
|
alloc.ClientStatus = structs.AllocClientStatusComplete
|
||||||
noErr(t, h.State.UpsertAllocs(h.NextIndex(), []*structs.Allocation{alloc}))
|
noErr(t, h.State.UpsertAllocs(h.NextIndex(), []*structs.Allocation{alloc}))
|
||||||
|
|
||||||
// Create a mock evaluation to register the job
|
// Create a mock evaluation to register the job
|
||||||
|
|
Loading…
Reference in New Issue