Update memberlist for the node renaming change
This commit is contained in:
parent
df4ec913f0
commit
106fde20b3
|
@ -7,8 +7,8 @@ package memberlist
|
||||||
// a node out and prevent it from being considered a peer
|
// a node out and prevent it from being considered a peer
|
||||||
// using application specific logic.
|
// using application specific logic.
|
||||||
type AliveDelegate interface {
|
type AliveDelegate interface {
|
||||||
// NotifyMerge is invoked when a merge could take place.
|
// NotifyAlive is invoked when a message about a live
|
||||||
// Provides a list of the nodes known by the peer. If
|
// node is received from the network. Returning a non-nil
|
||||||
// the return value is non-nil, the merge is canceled.
|
// error prevents the node from being considered a peer.
|
||||||
NotifyAlive(peer *Node) error
|
NotifyAlive(peer *Node) error
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/armon/go-metrics"
|
metrics "github.com/armon/go-metrics"
|
||||||
)
|
)
|
||||||
|
|
||||||
type nodeStateType int
|
type nodeStateType int
|
||||||
|
@ -891,6 +891,7 @@ func (m *Memberlist) aliveNode(a *alive, notify chan struct{}, bootstrap bool) {
|
||||||
|
|
||||||
// Check if we've never seen this node before, and if not, then
|
// Check if we've never seen this node before, and if not, then
|
||||||
// store this node in our node map.
|
// store this node in our node map.
|
||||||
|
var updatesNode bool
|
||||||
if !ok {
|
if !ok {
|
||||||
state = &nodeState{
|
state = &nodeState{
|
||||||
Node: Node{
|
Node: Node{
|
||||||
|
@ -926,12 +927,17 @@ func (m *Memberlist) aliveNode(a *alive, notify chan struct{}, bootstrap bool) {
|
||||||
|
|
||||||
// Update numNodes after we've added a new node
|
// Update numNodes after we've added a new node
|
||||||
atomic.AddUint32(&m.numNodes, 1)
|
atomic.AddUint32(&m.numNodes, 1)
|
||||||
}
|
} else {
|
||||||
|
// Check if this address is different than the existing node unless the old node is dead.
|
||||||
// Check if this address is different than the existing node
|
|
||||||
if !bytes.Equal([]byte(state.Addr), a.Addr) || state.Port != a.Port {
|
if !bytes.Equal([]byte(state.Addr), a.Addr) || state.Port != a.Port {
|
||||||
m.logger.Printf("[ERR] memberlist: Conflicting address for %s. Mine: %v:%d Theirs: %v:%d",
|
// Allow the address to be updated if a dead node is being replaced.
|
||||||
|
if state.State == stateDead {
|
||||||
|
m.logger.Printf("[INFO] memberlist: Updating address for failed node %s from %v:%d to %v:%d",
|
||||||
state.Name, state.Addr, state.Port, net.IP(a.Addr), a.Port)
|
state.Name, state.Addr, state.Port, net.IP(a.Addr), a.Port)
|
||||||
|
updatesNode = true
|
||||||
|
} else {
|
||||||
|
m.logger.Printf("[ERR] memberlist: Conflicting address for %s. Mine: %v:%d Theirs: %v:%d Old state: %v",
|
||||||
|
state.Name, state.Addr, state.Port, net.IP(a.Addr), a.Port, state.State)
|
||||||
|
|
||||||
// Inform the conflict delegate if provided
|
// Inform the conflict delegate if provided
|
||||||
if m.config.Conflict != nil {
|
if m.config.Conflict != nil {
|
||||||
|
@ -945,10 +951,12 @@ func (m *Memberlist) aliveNode(a *alive, notify chan struct{}, bootstrap bool) {
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Bail if the incarnation number is older, and this is not about us
|
// Bail if the incarnation number is older, and this is not about us
|
||||||
isLocalNode := state.Name == m.config.Name
|
isLocalNode := state.Name == m.config.Name
|
||||||
if a.Incarnation <= state.Incarnation && !isLocalNode {
|
if a.Incarnation <= state.Incarnation && !isLocalNode && !updatesNode {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1006,6 +1014,8 @@ func (m *Memberlist) aliveNode(a *alive, notify chan struct{}, bootstrap bool) {
|
||||||
// Update the state and incarnation number
|
// Update the state and incarnation number
|
||||||
state.Incarnation = a.Incarnation
|
state.Incarnation = a.Incarnation
|
||||||
state.Meta = a.Meta
|
state.Meta = a.Meta
|
||||||
|
state.Addr = a.Addr
|
||||||
|
state.Port = a.Port
|
||||||
if state.State != stateAlive {
|
if state.State != stateAlive {
|
||||||
state.State = stateAlive
|
state.State = stateAlive
|
||||||
state.StateChange = time.Now()
|
state.StateChange = time.Now()
|
||||||
|
|
|
@ -146,7 +146,7 @@
|
||||||
{"path":"github.com/hashicorp/hil","checksumSHA1":"kqCMCHy2b+RBMKC+ER+OPqp8C3E=","revision":"1e86c6b523c55d1fa6c6e930ce80b548664c95c2","revisionTime":"2016-07-11T23:18:37Z"},
|
{"path":"github.com/hashicorp/hil","checksumSHA1":"kqCMCHy2b+RBMKC+ER+OPqp8C3E=","revision":"1e86c6b523c55d1fa6c6e930ce80b548664c95c2","revisionTime":"2016-07-11T23:18:37Z"},
|
||||||
{"path":"github.com/hashicorp/hil/ast","checksumSHA1":"UICubs001+Q4MsUf9zl2vcMzWQQ=","revision":"1e86c6b523c55d1fa6c6e930ce80b548664c95c2","revisionTime":"2016-07-11T23:18:37Z"},
|
{"path":"github.com/hashicorp/hil/ast","checksumSHA1":"UICubs001+Q4MsUf9zl2vcMzWQQ=","revision":"1e86c6b523c55d1fa6c6e930ce80b548664c95c2","revisionTime":"2016-07-11T23:18:37Z"},
|
||||||
{"path":"github.com/hashicorp/logutils","checksumSHA1":"vt+P9D2yWDO3gdvdgCzwqunlhxU=","revision":"0dc08b1671f34c4250ce212759ebd880f743d883","revisionTime":"2015-06-09T07:04:31Z"},
|
{"path":"github.com/hashicorp/logutils","checksumSHA1":"vt+P9D2yWDO3gdvdgCzwqunlhxU=","revision":"0dc08b1671f34c4250ce212759ebd880f743d883","revisionTime":"2015-06-09T07:04:31Z"},
|
||||||
{"path":"github.com/hashicorp/memberlist","checksumSHA1":"j4pWTjW3SFOPVwWBEZPuNHETnLE=","revision":"b38abf62d7f3ce5225722cd62a90cfb098e02519","revisionTime":"2019-02-04T18:04:39Z"},
|
{"path":"github.com/hashicorp/memberlist","checksumSHA1":"8aXKnwU1vIeum/LaFtp2O6H0/+Y=","revision":"11f323a32dc835ba6ce39cde2b04919a6bfd32ec","revisionTime":"2019-03-13T22:54:10Z"},
|
||||||
{"path":"github.com/hashicorp/net-rpc-msgpackrpc","checksumSHA1":"qnlqWJYV81ENr61SZk9c65R1mDo=","revision":"a14192a58a694c123d8fe5481d4a4727d6ae82f3","revisionTime":"2015-11-16T02:03:38Z"},
|
{"path":"github.com/hashicorp/net-rpc-msgpackrpc","checksumSHA1":"qnlqWJYV81ENr61SZk9c65R1mDo=","revision":"a14192a58a694c123d8fe5481d4a4727d6ae82f3","revisionTime":"2015-11-16T02:03:38Z"},
|
||||||
{"path":"github.com/hashicorp/raft","checksumSHA1":"3U9bQLEMikE47n4TZP6uOdgXIyQ=","revision":"da92cfe76e0c1c9b94bbc9d884ec4b2b3b90b699","revisionTime":"2018-08-17T18:12:11Z","version":"master","versionExact":"master"},
|
{"path":"github.com/hashicorp/raft","checksumSHA1":"3U9bQLEMikE47n4TZP6uOdgXIyQ=","revision":"da92cfe76e0c1c9b94bbc9d884ec4b2b3b90b699","revisionTime":"2018-08-17T18:12:11Z","version":"master","versionExact":"master"},
|
||||||
{"path":"github.com/hashicorp/raft-boltdb","checksumSHA1":"QAxukkv54/iIvLfsUP6IK4R0m/A=","revision":"d1e82c1ec3f15ee991f7cc7ffd5b67ff6f5bbaee","revisionTime":"2015-02-01T20:08:39Z"},
|
{"path":"github.com/hashicorp/raft-boltdb","checksumSHA1":"QAxukkv54/iIvLfsUP6IK4R0m/A=","revision":"d1e82c1ec3f15ee991f7cc7ffd5b67ff6f5bbaee","revisionTime":"2015-02-01T20:08:39Z"},
|
||||||
|
|
Loading…
Reference in New Issue