Skip to content

Commit

Permalink
Add os to NodeListStub struct.
Browse files Browse the repository at this point in the history
Signed-off-by: Shishir Mahajan <smahajan@roblox.com>
  • Loading branch information
shishir-a412ed committed Apr 5, 2022
1 parent 4042c28 commit d5ad2c5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
1 change: 1 addition & 0 deletions api/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,7 @@ func (v *StatValue) String() string {
type NodeListStub struct {
Address string
ID string
OS string
Datacenter string
Name string
NodeClass string
Expand Down
12 changes: 1 addition & 11 deletions command/node_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,24 +231,14 @@ func (c *NodeStatusCommand) Run(args []string) int {
out[0] += "|Running Allocs"
}

queryOptions := &api.QueryOptions{AllowStale: true}
var nodeInfo *api.Node

for i, node := range nodes {
if c.os {
nodeInfo, _, err = client.Nodes().Info(node.ID, queryOptions)
if err != nil {
c.Ui.Error(fmt.Sprintf("Error getting node info: %s", err))
return 1
}
}
out[i+1] = fmt.Sprintf("%s|%s|%s|%s",
limit(node.ID, c.length),
node.Datacenter,
node.Name,
node.NodeClass)
if c.os {
out[i+1] += fmt.Sprintf("|%s", nodeInfo.Attributes["os.name"])
out[i+1] += fmt.Sprintf("|%s", node.OS)
}
if c.verbose {
out[i+1] += fmt.Sprintf("|%s|%s",
Expand Down
2 changes: 2 additions & 0 deletions nomad/structs/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2191,6 +2191,7 @@ func (n *Node) Stub(fields *NodeStubFields) *NodeListStub {
s := &NodeListStub{
Address: addr,
ID: n.ID,
OS: n.Attributes["os.name"],
Datacenter: n.Datacenter,
Name: n.Name,
NodeClass: n.NodeClass,
Expand Down Expand Up @@ -2221,6 +2222,7 @@ func (n *Node) Stub(fields *NodeStubFields) *NodeListStub {
type NodeListStub struct {
Address string
ID string
OS string
Datacenter string
Name string
NodeClass string
Expand Down

0 comments on commit d5ad2c5

Please sign in to comment.