From 1c441d4fdc2a39646f461798297acdab5662feaf Mon Sep 17 00:00:00 2001 From: Luiz Aoqui Date: Fri, 2 Jun 2023 18:50:40 -0400 Subject: [PATCH] reorder Allocation fields and add changelog entry --- .changelog/17280.txt | 3 +++ api/allocations.go | 2 +- api/allocations_test.go | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 .changelog/17280.txt diff --git a/.changelog/17280.txt b/.changelog/17280.txt new file mode 100644 index 00000000000..621dba8955d --- /dev/null +++ b/.changelog/17280.txt @@ -0,0 +1,3 @@ +```release-note:bug +api: add missing field NetworkStatus for Allocation +``` diff --git a/api/allocations.go b/api/allocations.go index 18a2f08fcab..0e49252b43c 100644 --- a/api/allocations.go +++ b/api/allocations.go @@ -270,6 +270,7 @@ type Allocation struct { PreviousAllocation string NextAllocation string RescheduleTracker *RescheduleTracker + NetworkStatus *AllocNetworkStatus PreemptedAllocations []string PreemptedByAllocation string CreateIndex uint64 @@ -277,7 +278,6 @@ type Allocation struct { AllocModifyIndex uint64 CreateTime int64 ModifyTime int64 - NetworkStatus *AllocNetworkStatus } // AllocationMetric is used to deserialize allocation metrics. diff --git a/api/allocations_test.go b/api/allocations_test.go index 71586e0047f..a5d49ad7348 100644 --- a/api/allocations_test.go +++ b/api/allocations_test.go @@ -161,6 +161,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)