From da27fc388068d77e7e01548cf84b1056c87f4405 Mon Sep 17 00:00:00 2001 From: Alex Dadgar Date: Thu, 22 Mar 2018 17:18:32 -0700 Subject: [PATCH] Driver Info output --- client/driver/docker.go | 2 +- command/node_status.go | 31 +++++++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/client/driver/docker.go b/client/driver/docker.go index e5ffb1afa..fc724ccc4 100644 --- a/client/driver/docker.go +++ b/client/driver/docker.go @@ -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`") dinfo.Healthy = true - dinfo.HealthDescription = "Docker driver is available and responsive" + dinfo.HealthDescription = "Driver is available and responsive" resp.AddDriverInfo("docker", dinfo) return nil } diff --git a/command/node_status.go b/command/node_status.go index 68c72342b..23c17eff0 100644 --- a/command/node_status.go +++ b/command/node_status.go @@ -306,10 +306,10 @@ func (c *NodeStatusCommand) formatNode(client *api.Client, node *api.Node) int { fmt.Sprintf("Drain|%v", node.Drain), fmt.Sprintf("Eligibility|%s", node.SchedulingEligibility), fmt.Sprintf("Status|%s", node.Status), - fmt.Sprintf("Drivers|%s", strings.Join(nodeDrivers(node), ",")), } if c.short { + basic = append(basic, fmt.Sprintf("Drivers|%s", strings.Join(nodeDrivers(node), ","))) c.Ui.Output(c.Colorize().Color(formatKV(basic))) } else { // 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))) + // Emit the driver info + c.outputNodeDriverInfo(node) + + // Emit node events c.outputNodeStatusEvents(node) // Get list of running allocations on the node @@ -380,8 +384,31 @@ 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) { - c.Ui.Output(c.Colorize().Color("\n[bold]Node Events ")) + c.Ui.Output(c.Colorize().Color("\n[bold]Node Events")) c.outputNodeEvent(node.Events) }