Show info about remaining reschedule attempts relative to alloc modify time

This commit is contained in:
Preetha Appan 2018-01-25 12:48:17 -06:00
parent 5714a6b8bf
commit 36b8e91625
No known key found for this signature in database
GPG Key ID: 9F7C19990A50EAFC
2 changed files with 5 additions and 9 deletions

View File

@ -287,8 +287,9 @@ func formatAllocBasicInfo(alloc *api.Allocation, client *api.Client, uuidLength
fmt.Sprintf("Allocation Time|%s", alloc.Metrics.AllocationTime),
fmt.Sprintf("Failures|%d", alloc.Metrics.CoalescedFailures))
if alloc.RescheduleTracker != nil && len(alloc.RescheduleTracker.Events) > 0 {
basic = append(basic,
fmt.Sprintf("Previous Reschedule Attempts|%d", len(alloc.RescheduleTracker.Events)))
attempts, total := alloc.RescheduleInfo(time.Unix(0, alloc.ModifyTime))
reschedInfo := fmt.Sprintf("Remaining Reschedule Attempts|%d/%d", attempts, total)
basic = append(basic, reschedInfo)
}
}

View File

@ -183,12 +183,7 @@ func TestAllocStatusCommand_Run(t *testing.T) {
a.RescheduleTracker = &structs.RescheduleTracker{
Events: []*structs.RescheduleEvent{
{
RescheduleTime: time.Now().Add(-5 * time.Minute).UTC().UnixNano(),
PrevAllocID: uuid.Generate(),
PrevNodeID: uuid.Generate(),
},
{
RescheduleTime: time.Now().Add(-5 * time.Minute).UTC().UnixNano(),
RescheduleTime: time.Now().Add(-2 * time.Minute).UTC().UnixNano(),
PrevAllocID: uuid.Generate(),
PrevNodeID: uuid.Generate(),
},
@ -206,7 +201,7 @@ func TestAllocStatusCommand_Run(t *testing.T) {
t.Fatalf("expected exit 0, got: %d", code)
}
out = ui.OutputWriter.String()
require.Contains(out, "Previous Reschedule Attempts")
require.Contains(out, "Remaining Reschedule Attempts = 1/2")
}