mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
command: adjustments to monitor logs
This commit is contained in:
@@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user