command: adjustments to monitor logs

This commit is contained in:
Ryan Uber
2015-09-21 12:53:48 -07:00
parent 2f5c40cb4b
commit 4445730c67
2 changed files with 12 additions and 8 deletions

View File

@@ -131,21 +131,23 @@ func (m *monitor) update(update *evalState) {
}
}
// Check if the status changed
if existing.status != update.status {
// Check if the status changed. We skip any transitions to pending status.
if existing.status != "" &&
update.status != structs.AllocClientStatusPending &&
existing.status != update.status {
m.ui.Output(fmt.Sprintf("Evaluation status changed: %q -> %q",
existing.status, update.status))
}
// Check if the wait time is different
if existing.wait == 0 && update.wait != 0 {
m.ui.Output(fmt.Sprintf("Waiting %s before running eval",
m.ui.Output(fmt.Sprintf("Evaluation delay is %s",
update.wait))
}
// Check if the node changed
// Check if the evaluation was triggered by a node
if existing.node == "" && update.node != "" {
m.ui.Output(fmt.Sprintf("Evaluation was assigned node ID %q",
m.ui.Output(fmt.Sprintf("Evaluation triggered by node %q",
update.node))
}
}

View File

@@ -24,15 +24,17 @@ func TestMonitor_Update_Eval(t *testing.T) {
// Logs were output
out := ui.OutputWriter.String()
if !strings.Contains(out, "pending") {
t.Fatalf("missing status\n\n%s", out)
}
if !strings.Contains(out, "node1") {
t.Fatalf("missing node\n\n%s", out)
}
if !strings.Contains(out, "10s") {
t.Fatalf("missing eval wait\n\n%s", out)
}
// Transition to pending should not be logged
if strings.Contains(out, structs.EvalStatusPending) {
t.Fatalf("should skip status\n\n%s", out)
}
ui.OutputWriter.Reset()
// No logs sent if no update