Skip to content

Commit

Permalink
Merge pull request #1593 from hashicorp/f-rereg
Browse files Browse the repository at this point in the history
Reregister Client on failed heartbeat
  • Loading branch information
dadgar committed Aug 16, 2016
2 parents 580596e + 134dbb1 commit 0722e54
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"os"
"path/filepath"
"strconv"
"strings"
"sync"
"sync/atomic"
"time"
Expand Down Expand Up @@ -737,7 +738,17 @@ func (c *Client) registerAndHeartbeat() {
select {
case <-heartbeat:
if err := c.updateNodeStatus(); err != nil {
heartbeat = time.After(c.retryIntv(registerRetryIntv))
// The servers have changed such that this node has not been
// registered before
if strings.Contains(err.Error(), "node not found") {
// Re-register the node
c.logger.Printf("[INFO] client: re-registering node")
c.retryRegisterNode()
heartbeat = time.After(lib.RandomStagger(initialHeartbeatStagger))
} else {
c.logger.Printf("[ERR] client: heartbeating failed: %v", err)
heartbeat = time.After(c.retryIntv(registerRetryIntv))
}
} else {
c.heartbeatLock.Lock()
heartbeat = time.After(c.heartbeatTTL)
Expand Down

0 comments on commit 0722e54

Please sign in to comment.