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

Add the Nomad agent version to the node-status CLI output. #3002

Merged
merged 2 commits into from
Aug 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions api/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ type NodeListStub struct {
Datacenter string
Name string
NodeClass string
Version string
Drain bool
Status string
StatusDescription string
Expand Down
43 changes: 24 additions & 19 deletions command/node_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Node Status Options:
-self
Query the status of the local node.

-stats
-stats
Display detailed resource usage statistics.

-allocs
Expand Down Expand Up @@ -148,35 +148,40 @@ func (c *NodeStatusCommand) Run(args []string) int {

// Format the nodes list
out := make([]string, len(nodes)+1)

out[0] = "ID|DC|Name|Class|"

if c.verbose {
out[0] += "Version|"
}

out[0] += "Drain|Status"

if c.list_allocs {
out[0] = "ID|DC|Name|Class|Drain|Status|Running Allocs"
} else {
out[0] = "ID|DC|Name|Class|Drain|Status"
out[0] += "|Running Allocs"
}

for i, node := range nodes {
out[i+1] = fmt.Sprintf("%s|%s|%s|%s",
limit(node.ID, c.length),
node.Datacenter,
node.Name,
node.NodeClass)
if c.verbose {
out[i+1] += fmt.Sprintf("|%s",
node.Version)
}
out[i+1] += fmt.Sprintf("|%v|%s",
node.Drain,
node.Status)
if c.list_allocs {
numAllocs, err := getRunningAllocs(client, node.ID)
if err != nil {
c.Ui.Error(fmt.Sprintf("Error querying node allocations: %s", err))
return 1
}
out[i+1] = fmt.Sprintf("%s|%s|%s|%s|%v|%s|%v",
limit(node.ID, c.length),
node.Datacenter,
node.Name,
node.NodeClass,
node.Drain,
node.Status,
out[i+1] += fmt.Sprintf("|%v",
len(numAllocs))
} else {
out[i+1] = fmt.Sprintf("%s|%s|%s|%s|%v|%s",
limit(node.ID, c.length),
node.Datacenter,
node.Name,
node.NodeClass,
node.Drain,
node.Status)
}
}

Expand Down
2 changes: 2 additions & 0 deletions nomad/structs/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,7 @@ func (n *Node) Stub() *NodeListStub {
Datacenter: n.Datacenter,
Name: n.Name,
NodeClass: n.NodeClass,
Version: n.Attributes["nomad.version"],
Drain: n.Drain,
Status: n.Status,
StatusDescription: n.StatusDescription,
Expand All @@ -1072,6 +1073,7 @@ type NodeListStub struct {
Datacenter string
Name string
NodeClass string
Version string
Drain bool
Status string
StatusDescription string
Expand Down