client: avoid registering node twice right away

I noticed that `watchNodeUpdates()` almost immediately after
`registerAndHeartbeat()` calls `retryRegisterNode()`, well after 5
seconds.

This call is unnecessary and made debugging a bit harder.  So here, we
ensure that we only re-register node for new node events, not for
initial registration.
This commit is contained in:
Mahmood Ali
2019-04-19 09:12:50 -04:00
parent 7a68d76160
commit 9dcebcd8a3
2 changed files with 14 additions and 8 deletions

View File

@@ -1468,13 +1468,7 @@ func (c *Client) watchNodeEvents() {
// batchEvents stores events that have yet to be published
var batchEvents []*structs.NodeEvent
// Create and drain the timer
timer := time.NewTimer(0)
timer.Stop()
select {
case <-timer.C:
default:
}
timer := stoppedTimer()
defer timer.Stop()
for {
@@ -1930,7 +1924,8 @@ func (c *Client) updateNodeLocked() {
// it will update the client node copy and re-register the node.
func (c *Client) watchNodeUpdates() {
var hasChanged bool
timer := time.NewTimer(c.retryIntv(nodeUpdateRetryIntv))
timer := stoppedTimer()
defer timer.Stop()
for {