Skip to content

Commit

Permalink
Updates based on feedback provided by dadgar.
Browse files Browse the repository at this point in the history
  • Loading branch information
jrasell committed Aug 16, 2017
1 parent 113e9b0 commit fe481ae
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 30 deletions.
2 changes: 1 addition & 1 deletion api/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ type NodeListStub struct {
Datacenter string
Name string
NodeClass string
Build string
Version string
Drain bool
Status string
StatusDescription string
Expand Down
1 change: 0 additions & 1 deletion command/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,6 @@ func (a *Agent) clientConfig() (*clientconfig.Config, error) {
conf.Node.Name = a.config.NodeName
conf.Node.Meta = a.config.Client.Meta
conf.Node.NodeClass = a.config.Client.NodeClass
conf.Node.Build = fmt.Sprintf("%s%s", a.config.Version, a.config.VersionPrerelease)

// Set up the HTTP advertise address
conf.Node.HTTPAddr = a.config.AdvertiseAddrs.HTTP
Expand Down
48 changes: 25 additions & 23 deletions command/node_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,37 +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|Build|Drain|Status|Running Allocs"
} else {
out[0] = "ID|DC|Name|Class|Build|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|%s|%v|%s|%v",
limit(node.ID, c.length),
node.Datacenter,
node.Name,
node.NodeClass,
node.Build,
node.Drain,
node.Status,
out[i+1] += fmt.Sprintf("|%v",
len(numAllocs))
} else {
out[i+1] = fmt.Sprintf("%s|%s|%s|%s|%s|%v|%s",
limit(node.ID, c.length),
node.Datacenter,
node.Name,
node.NodeClass,
node.Build,
node.Drain,
node.Status)
}
}

Expand Down Expand Up @@ -222,14 +225,13 @@ func (c *NodeStatusCommand) Run(args []string) int {
// Format the nodes list that matches the prefix so that the user
// can create a more specific request
out := make([]string, len(nodes)+1)
out[0] = "ID|DC|Name|Class|Build|Drain|Status"
out[0] = "ID|DC|Name|Class|Drain|Status"
for i, node := range nodes {
out[i+1] = fmt.Sprintf("%s|%s|%s|%s|%s|%v|%s",
out[i+1] = fmt.Sprintf("%s|%s|%s|%s|%v|%s",
limit(node.ID, c.length),
node.Datacenter,
node.Name,
node.NodeClass,
node.Build,
node.Drain,
node.Status)
}
Expand Down
7 changes: 2 additions & 5 deletions nomad/structs/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -996,9 +996,6 @@ type Node struct {
// together for the purpose of determining scheduling pressure.
NodeClass string

// Build represents the Nomad version the node is running
Build string

// ComputedClass is a unique id that identifies nodes with a common set of
// attributes and capabilities.
ComputedClass string
Expand Down Expand Up @@ -1060,7 +1057,7 @@ func (n *Node) Stub() *NodeListStub {
Datacenter: n.Datacenter,
Name: n.Name,
NodeClass: n.NodeClass,
Build: n.Build,
Version: n.Attributes["nomad.version"],
Drain: n.Drain,
Status: n.Status,
StatusDescription: n.StatusDescription,
Expand All @@ -1076,7 +1073,7 @@ type NodeListStub struct {
Datacenter string
Name string
NodeClass string
Build string
Version string
Drain bool
Status string
StatusDescription string
Expand Down

0 comments on commit fe481ae

Please sign in to comment.