api: emit different monitor message if node's drain strategy is never set

This commit is contained in:
Nick Ethier 2018-05-22 14:35:42 -04:00
parent b1d2437cf6
commit 4b64db3a0f
No known key found for this signature in database
GPG Key ID: 07C1A3ECED90D24A
1 changed files with 8 additions and 1 deletions

View File

@ -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,
@ -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():
@ -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