From e7b25a25014a3b332e632eb811c5b237cda9adab Mon Sep 17 00:00:00 2001 From: hc-github-team-nomad-core <82989552+hc-github-team-nomad-core@users.noreply.github.com> Date: Wed, 3 Apr 2024 08:06:44 -0500 Subject: [PATCH] Backport of api: add missing AllocDirStats field in Go API into release/1.5.x (#20271) Co-authored-by: Tim Gross --- .changelog/20261.txt | 3 +++ api/nodes.go | 1 + api/nodes_test.go | 21 +++++++++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 .changelog/20261.txt diff --git a/.changelog/20261.txt b/.changelog/20261.txt new file mode 100644 index 000000000000..6a63d747ab44 --- /dev/null +++ b/.changelog/20261.txt @@ -0,0 +1,3 @@ +```release-note:bug +api: Fixed a bug where `AllocDirStats` field was missing from Read Stats client API +``` diff --git a/api/nodes.go b/api/nodes.go index a16191df80c0..ad900c6902ef 100644 --- a/api/nodes.go +++ b/api/nodes.go @@ -782,6 +782,7 @@ type HostStats struct { Memory *HostMemoryStats CPU []*HostCPUStats DiskStats []*HostDiskStats + AllocDirStats *HostDiskStats DeviceStats []*DeviceGroupStats Uptime uint64 CPUTicksConsumed float64 diff --git a/api/nodes_test.go b/api/nodes_test.go index 0ab48a8fd436..11071f256dd0 100644 --- a/api/nodes_test.go +++ b/api/nodes_test.go @@ -151,6 +151,27 @@ func TestNodes_Info(t *testing.T) { must.GreaterEq(t, 1, len(result.Events)) } +func TestNode_Stats(t *testing.T) { + testutil.Parallel(t) + + c, s := makeClient(t, nil, func(c *testutil.TestServerConfig) { + c.DevMode = true + }) + defer s.Stop() + nodesAPI := c.Nodes() + nodeID := oneNodeFromNodeList(t, nodesAPI).ID + + stats, err := nodesAPI.Stats(nodeID, nil) + must.NoError(t, err) + + // there isn't much we can reliably check here except that the values are + // populated + must.NotNil(t, stats.Memory) + must.NonZero(t, stats.Memory.Available) + must.NotNil(t, stats.AllocDirStats) + must.NonZero(t, stats.AllocDirStats.Size) +} + func TestNodes_NoSecretID(t *testing.T) { testutil.Parallel(t)