Accounting lost state of allocations
This commit is contained in:
parent
e8d1aee3f4
commit
00b9b4c6e8
|
@ -1299,6 +1299,8 @@ func (s *StateStore) updateSummaryWithAlloc(newAlloc *structs.Allocation,
|
|||
tgSummary.Starting += 1
|
||||
case structs.AllocClientStatusComplete:
|
||||
tgSummary.Complete += 1
|
||||
case structs.AllocClientStatusLost:
|
||||
tgSummary.Lost += 1
|
||||
}
|
||||
|
||||
// Decrementing the count of the bin of the last state
|
||||
|
@ -1311,21 +1313,8 @@ func (s *StateStore) updateSummaryWithAlloc(newAlloc *structs.Allocation,
|
|||
tgSummary.Starting -= 1
|
||||
case structs.AllocClientStatusComplete:
|
||||
tgSummary.Complete -= 1
|
||||
}
|
||||
} else if existingAlloc.DesiredStatus != newAlloc.DesiredStatus {
|
||||
shouldDecrementStarting := false
|
||||
switch newAlloc.DesiredStatus {
|
||||
case structs.AllocDesiredStatusFailed:
|
||||
tgSummary.Failed += 1
|
||||
shouldDecrementStarting = true
|
||||
case structs.AllocDesiredStatusStop:
|
||||
tgSummary.Complete += 1
|
||||
shouldDecrementStarting = true
|
||||
}
|
||||
if shouldDecrementStarting {
|
||||
if newAlloc.ClientStatus == structs.AllocClientStatusPending {
|
||||
tgSummary.Starting -= 1
|
||||
}
|
||||
case structs.AllocClientStatusLost:
|
||||
tgSummary.Lost -= 1
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2369,12 +2369,14 @@ func TestStateJobSummary_UpdateJobCount(t *testing.T) {
|
|||
alloc4.Job = alloc2.Job
|
||||
alloc4.JobID = alloc2.JobID
|
||||
alloc4.DesiredStatus = structs.AllocDesiredStatusStop
|
||||
alloc4.ClientStatus = structs.AllocClientStatusComplete
|
||||
|
||||
alloc5 := mock.Alloc()
|
||||
alloc5.ID = alloc3.ID
|
||||
alloc5.Job = alloc3.Job
|
||||
alloc5.JobID = alloc3.JobID
|
||||
alloc5.DesiredStatus = structs.AllocDesiredStatusStop
|
||||
alloc5.ClientStatus = structs.AllocClientStatusComplete
|
||||
|
||||
if err := state.UpsertAllocs(1004, []*structs.Allocation{alloc4, alloc5}); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
|
|
|
@ -955,6 +955,7 @@ type TaskGroupSummary struct {
|
|||
Failed int
|
||||
Running int
|
||||
Starting int
|
||||
Lost int
|
||||
}
|
||||
|
||||
// Total returns the total number of allocations for the task group.
|
||||
|
|
Loading…
Reference in New Issue