From 306a6dc81ff1da3191e8035517b4f08b9045ae20 Mon Sep 17 00:00:00 2001 From: Ryan Uber Date: Mon, 21 Sep 2015 16:20:50 -0700 Subject: [PATCH] command: print a warning if we get 0 evaluated nodes --- command/monitor.go | 5 +++++ command/monitor_test.go | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/command/monitor.go b/command/monitor.go index b72979835..e0b020f20 100644 --- a/command/monitor.go +++ b/command/monitor.go @@ -272,6 +272,11 @@ func dumpAllocStatus(ui cli.Ui, alloc *api.Allocation) { alloc.ID, alloc.ClientStatus, alloc.Metrics.NodesFiltered, alloc.Metrics.NodesEvaluated)) + // Print a helpful message if we have an eligibility problem + if alloc.Metrics.NodesEvaluated == 0 { + ui.Output(" * No nodes were eligible for evaluation") + } + // Print filter info for class, num := range alloc.Metrics.ClassFiltered { ui.Output(fmt.Sprintf(" * Class %q filtered %d nodes", class, num)) diff --git a/command/monitor_test.go b/command/monitor_test.go index 646b188ae..dbb474561 100644 --- a/command/monitor_test.go +++ b/command/monitor_test.go @@ -326,4 +326,15 @@ func TestMonitor_DumpAllocStatus(t *testing.T) { if !strings.Contains(out, `Dimension "cpu" exhausted on 1 nodes`) { t.Fatalf("missing dimension exhaustion\n\n%s", out) } + ui.OutputWriter.Reset() + + // Dumping alloc status with no eligible nodes adds a warning + alloc.Metrics.NodesEvaluated = 0 + dumpAllocStatus(ui, alloc) + + // Check the output + out = ui.OutputWriter.String() + if !strings.Contains(out, "No nodes were eligible") { + t.Fatalf("missing eligibility warning\n\n%s", out) + } }