Skip to content

Commit

Permalink
Merge 1c441d4 into backport/main/smoothly-sacred-sturgeon
Browse files Browse the repository at this point in the history
  • Loading branch information
hc-github-team-nomad-core committed Jul 4, 2023
2 parents 29410c4 + 1c441d4 commit de79fcb
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .changelog/17280.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
api: add missing field NetworkStatus for Allocation
```
2 changes: 1 addition & 1 deletion api/allocations.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,14 +246,14 @@ type Allocation struct {
PreviousAllocation string
NextAllocation string
RescheduleTracker *RescheduleTracker
NetworkStatus *AllocNetworkStatus
PreemptedAllocations []string
PreemptedByAllocation string
CreateIndex uint64
ModifyIndex uint64
AllocModifyIndex uint64
CreateTime int64
ModifyTime int64
NetworkStatus *AllocNetworkStatus
}

// AllocationMetric is used to deserialize allocation metrics.
Expand Down
40 changes: 40 additions & 0 deletions api/allocations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,46 @@ func TestAllocations_CreateIndexSort(t *testing.T) {
must.Eq(t, allocs, expect)
}

func TestAllocations_Info(t *testing.T) {
testutil.RequireRoot(t)
testutil.Parallel(t)

c, s := makeClient(t, nil, func(c *testutil.TestServerConfig) {
c.DevMode = true
})
defer s.Stop()
a := c.Allocations()

// wait for node
_ = oneNodeFromNodeList(t, c.Nodes())

// Create a job and attempt to register it
job := testJob()
resp, wm, err := c.Jobs().Register(job, nil)
must.NoError(t, err)
must.NotNil(t, resp)
must.UUIDv4(t, resp.EvalID)
assertWriteMeta(t, wm)

// List allocations.
qo := &QueryOptions{
WaitIndex: wm.LastIndex,
}
allocs, qm, err := a.List(qo)
must.NoError(t, err)
must.NonZero(t, qm.LastIndex)

// Check that we got one allocation.
must.Len(t, 1, allocs)
must.Eq(t, resp.EvalID, allocs[0].EvalID)

// Fetch alloc info.
qo.WaitIndex = qm.LastIndex
alloc, _, err := a.Info(allocs[0].ID, qo)

must.NotNil(t, alloc.NetworkStatus)
}

func TestAllocations_RescheduleInfo(t *testing.T) {
testutil.Parallel(t)

Expand Down

0 comments on commit de79fcb

Please sign in to comment.