diff --git a/CHANGELOG.md b/CHANGELOG.md index 062fd2d7770a..ea823a82a880 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.8.4 (Unreleased) + +IMPROVEMENTS: + * cli: Add node drain details to node status + ## 0.8.3 (April 27, 2018) BUG FIXES: diff --git a/command/node_status.go b/command/node_status.go index 226c054fcd00..69f99acc0df2 100644 --- a/command/node_status.go +++ b/command/node_status.go @@ -4,6 +4,7 @@ import ( "fmt" "math" "sort" + "strconv" "strings" "time" @@ -299,6 +300,26 @@ func nodeDrivers(n *api.Node) []string { return drivers } +func nodeDrainString(n *api.Node) string { + if n.DrainStrategy != nil { + b := new(strings.Builder) + b.WriteString("true") + + if n.DrainStrategy.ForceDeadline.IsZero() { + b.WriteString("; no deadline") + } else { + fmt.Fprintf(b, "; %s deadline", formatTime(n.DrainStrategy.ForceDeadline)) + } + + if n.DrainStrategy.IgnoreSystemJobs { + b.WriteString("; ignoring system jobs") + } + return b.String() + } + + return strconv.FormatBool(n.Drain) +} + func (c *NodeStatusCommand) formatNode(client *api.Client, node *api.Node) int { // Format the header output basic := []string{ @@ -306,7 +327,7 @@ func (c *NodeStatusCommand) formatNode(client *api.Client, node *api.Node) int { fmt.Sprintf("Name|%s", node.Name), fmt.Sprintf("Class|%s", node.NodeClass), fmt.Sprintf("DC|%s", node.Datacenter), - fmt.Sprintf("Drain|%v", node.Drain), + fmt.Sprintf("Drain|%v", nodeDrainString(node)), fmt.Sprintf("Eligibility|%s", node.SchedulingEligibility), fmt.Sprintf("Status|%s", node.Status), }