mirror of
https://github.com/kemko/nomad.git
synced 2026-01-07 19:05:42 +03:00
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:
@@ -3,6 +3,7 @@ package client
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/nomad/nomad/structs"
|
||||
)
|
||||
@@ -63,3 +64,13 @@ func shuffleStrings(list []string) {
|
||||
list[i], list[j] = list[j], list[i]
|
||||
}
|
||||
}
|
||||
|
||||
// stoppedTimer returns a timer that's stopped and wouldn't fire until
|
||||
// it's reset
|
||||
func stoppedTimer() *time.Timer {
|
||||
timer := time.NewTimer(0)
|
||||
if !timer.Stop() {
|
||||
<-timer.C
|
||||
}
|
||||
return timer
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user