Skip to content

Commit

Permalink
api: emit different monitor message if node's drain strategy is never…
Browse files Browse the repository at this point in the history
… set
  • Loading branch information
nickethier committed May 22, 2018
1 parent 4f87413 commit a66d89b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion api/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ func (n *Nodes) monitorDrainNode(ctx context.Context, nodeID string, index uint6
defer close(nodeCh)

var lastStrategy *DrainStrategy
var strategyChanged bool
q := QueryOptions{
AllowStale: true,
WaitIndex: index,
Expand All @@ -209,7 +210,12 @@ func (n *Nodes) monitorDrainNode(ctx context.Context, nodeID string, index uint6
}

if node.DrainStrategy == nil {
msg := Messagef(MonitorMsgLevelInfo, "Node %q has marked all allocations for migration", nodeID)
var msg *MonitorMessage
if strategyChanged {
msg = Messagef(MonitorMsgLevelInfo, "Node %q has marked all allocations for migration", nodeID)
} else {
msg = Messagef(MonitorMsgLevelInfo, "No drain strategy set for node %s", nodeID)
}
select {
case nodeCh <- msg:
case <-ctx.Done():
Expand All @@ -236,6 +242,7 @@ func (n *Nodes) monitorDrainNode(ctx context.Context, nodeID string, index uint6
}

lastStrategy = node.DrainStrategy
strategyChanged = true

// Drain still ongoing, update index and block for updates
q.WaitIndex = meta.LastIndex
Expand Down

0 comments on commit a66d89b

Please sign in to comment.