command: print a warning if we get 0 evaluated nodes

This commit is contained in:
Ryan Uber 2015-09-21 16:20:50 -07:00
parent 75c79b705e
commit 306a6dc81f
2 changed files with 16 additions and 0 deletions

View file

@ -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))

View file

@ -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)
}
}