mirror of
https://github.com/kemko/nomad.git
synced 2026-01-05 01:45:44 +03:00
Add RescheduleTracker to allocations API struct
This commit is contained in:
@@ -97,6 +97,7 @@ type Allocation struct {
|
||||
AllocModifyIndex uint64
|
||||
CreateTime int64
|
||||
ModifyTime int64
|
||||
RescheduleTracker *RescheduleTracker
|
||||
}
|
||||
|
||||
// AllocationMetric is used to deserialize allocation metrics.
|
||||
@@ -135,6 +136,7 @@ type AllocationListStub struct {
|
||||
ModifyIndex uint64
|
||||
CreateTime int64
|
||||
ModifyTime int64
|
||||
RescheduleTracker *RescheduleTracker
|
||||
}
|
||||
|
||||
// AllocDeploymentStatus captures the status of the allocation as part of the
|
||||
@@ -159,3 +161,20 @@ func (a AllocIndexSort) Less(i, j int) bool {
|
||||
func (a AllocIndexSort) Swap(i, j int) {
|
||||
a[i], a[j] = a[j], a[i]
|
||||
}
|
||||
|
||||
// RescheduleTracker encapsulates previous reschedule events
|
||||
type RescheduleTracker struct {
|
||||
Events []*RescheduleEvent
|
||||
}
|
||||
|
||||
// RescheduleEvent is used to keep track of previous attempts at rescheduling an allocation
|
||||
type RescheduleEvent struct {
|
||||
// RescheduleTime is the timestamp of a reschedule attempt
|
||||
RescheduleTime int64
|
||||
|
||||
// PrevAllocID is the ID of the previous allocation being restarted
|
||||
PrevAllocID string
|
||||
|
||||
// PrevNodeID is the node ID of the previous allocation
|
||||
PrevNodeID string
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
|
||||
"github.com/hashicorp/net-rpc-msgpackrpc"
|
||||
"github.com/hashicorp/nomad/acl"
|
||||
"github.com/hashicorp/nomad/helper/uuid"
|
||||
"github.com/hashicorp/nomad/nomad/mock"
|
||||
"github.com/hashicorp/nomad/nomad/structs"
|
||||
"github.com/hashicorp/nomad/testutil"
|
||||
@@ -218,7 +219,13 @@ func TestAllocEndpoint_GetAlloc(t *testing.T) {
|
||||
testutil.WaitForLeader(t, s1.RPC)
|
||||
|
||||
// Create the register request
|
||||
prevAllocID := uuid.Generate()
|
||||
alloc := mock.Alloc()
|
||||
alloc.RescheduleTracker = &structs.RescheduleTracker{
|
||||
Events: []*structs.RescheduleEvent{
|
||||
{RescheduleTime: time.Now().UTC().UnixNano(), PrevNodeID: "boom", PrevAllocID: prevAllocID},
|
||||
},
|
||||
}
|
||||
state := s1.fsm.State()
|
||||
state.UpsertJobSummary(999, mock.JobSummary(alloc.JobID))
|
||||
err := state.UpsertAllocs(1000, []*structs.Allocation{alloc})
|
||||
|
||||
Reference in New Issue
Block a user