Merge pull request #4031 from hashicorp/f-node-driver-info

Driver Info CLI output
This commit is contained in:
Alex Dadgar 2018-03-22 17:20:42 -07:00 committed by GitHub
commit 85359120d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 3 deletions

View file

@ -577,7 +577,7 @@ func (d *DockerDriver) HealthCheck(req *cstructs.HealthCheckRequest, resp *cstru
d.logger.Printf("[TRACE] driver.docker: docker driver is available and is responsive to `docker ps`") d.logger.Printf("[TRACE] driver.docker: docker driver is available and is responsive to `docker ps`")
dinfo.Healthy = true dinfo.Healthy = true
dinfo.HealthDescription = "Docker driver is available and responsive" dinfo.HealthDescription = "Driver is available and responsive"
resp.AddDriverInfo("docker", dinfo) resp.AddDriverInfo("docker", dinfo)
return nil return nil
} }

View file

@ -306,10 +306,10 @@ func (c *NodeStatusCommand) formatNode(client *api.Client, node *api.Node) int {
fmt.Sprintf("Drain|%v", node.Drain), fmt.Sprintf("Drain|%v", node.Drain),
fmt.Sprintf("Eligibility|%s", node.SchedulingEligibility), fmt.Sprintf("Eligibility|%s", node.SchedulingEligibility),
fmt.Sprintf("Status|%s", node.Status), fmt.Sprintf("Status|%s", node.Status),
fmt.Sprintf("Drivers|%s", strings.Join(nodeDrivers(node), ",")),
} }
if c.short { if c.short {
basic = append(basic, fmt.Sprintf("Drivers|%s", strings.Join(nodeDrivers(node), ",")))
c.Ui.Output(c.Colorize().Color(formatKV(basic))) c.Ui.Output(c.Colorize().Color(formatKV(basic)))
} else { } else {
// Get the host stats // Get the host stats
@ -324,6 +324,10 @@ func (c *NodeStatusCommand) formatNode(client *api.Client, node *api.Node) int {
} }
c.Ui.Output(c.Colorize().Color(formatKV(basic))) c.Ui.Output(c.Colorize().Color(formatKV(basic)))
// Emit the driver info
c.outputNodeDriverInfo(node)
// Emit node events
c.outputNodeStatusEvents(node) c.outputNodeStatusEvents(node)
// Get list of running allocations on the node // Get list of running allocations on the node
@ -380,6 +384,29 @@ func (c *NodeStatusCommand) formatNode(client *api.Client, node *api.Node) int {
} }
func (c *NodeStatusCommand) outputNodeDriverInfo(node *api.Node) {
c.Ui.Output(c.Colorize().Color("\n[bold]Drivers"))
size := len(node.Drivers)
nodeDrivers := make([]string, 0, size+1)
if c.verbose {
nodeDrivers = append(nodeDrivers, "Driver|Detected|Healthy|Message|Time")
} else {
nodeDrivers = append(nodeDrivers, "Driver|Detected|Healthy")
}
for driver, info := range node.Drivers {
if c.verbose {
timestamp := formatTime(info.UpdateTime)
nodeDrivers = append(nodeDrivers, fmt.Sprintf("%s|%v|%v|%s|%s", driver, info.Detected, info.Healthy, info.HealthDescription, timestamp))
} else {
nodeDrivers = append(nodeDrivers, fmt.Sprintf("%s|%v|%v", driver, info.Detected, info.Healthy))
}
}
c.Ui.Output(formatList(nodeDrivers))
}
func (c *NodeStatusCommand) outputNodeStatusEvents(node *api.Node) { func (c *NodeStatusCommand) outputNodeStatusEvents(node *api.Node) {
c.Ui.Output(c.Colorize().Color("\n[bold]Node Events")) c.Ui.Output(c.Colorize().Color("\n[bold]Node Events"))
c.outputNodeEvent(node.Events) c.outputNodeEvent(node.Events)