Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api: add missing AllocDirStats field in Go API #20261

Merged
merged 2 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/20261.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
api: Fixed a bug where `AllocDirStats` field was missing from Reads Stats client API
tgross marked this conversation as resolved.
Show resolved Hide resolved
```
1 change: 1 addition & 0 deletions api/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,7 @@ type HostStats struct {
Memory *HostMemoryStats
CPU []*HostCPUStats
DiskStats []*HostDiskStats
AllocDirStats *HostDiskStats
DeviceStats []*DeviceGroupStats
Uptime uint64
CPUTicksConsumed float64
Expand Down
21 changes: 21 additions & 0 deletions api/nodes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,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()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah this is one of those little "node" vs "client" battlegrounds, eh?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah c is the Go API client, and c.Nodes() is the Nodes API in the Go API client. 😀

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was more pointing out that it hits the /client API, not /node! looks like there's no client.go to have something like c.Clients() presumably to avoid the name collision of "Nomad client" and "Nomad API client" ... so the Nodes{} (go) API on the (go) API Client{} is used to hit both the /nodes (http) API and the /client (http) API 😅

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah! Yeah, totally.

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)

Expand Down
Loading