Remove syncNodes/syncPeers not Ready special case
First the comment "so remove it from the mesh" is wrong / missleading as
since 034c27ab78
the delete in that if is
not in there anymore.
Second the m.nodes map is not updated so setting `diff = true` will call `applyTopology` without any changes... which seams useless.
Third the rest of the code already checks for Ready so this special case
here should not be needed.
This commit is contained in:
parent
863628ffaa
commit
81f592de74
@ -274,14 +274,10 @@ func (m *Mesh) syncNodes(e *NodeEvent) {
|
|||||||
var diff bool
|
var diff bool
|
||||||
m.mu.Lock()
|
m.mu.Lock()
|
||||||
if !e.Node.Ready() {
|
if !e.Node.Ready() {
|
||||||
level.Debug(logger).Log("msg", "received incomplete node", "node", e.Node)
|
// Trace non ready nodes with their presence in the mesh.
|
||||||
// An existing node is no longer valid
|
_, ok := m.nodes[e.Node.Name]
|
||||||
// so remove it from the mesh.
|
level.Debug(logger).Log("msg", "received non ready node", "node", e.Node, "in-mesh", ok)
|
||||||
if _, ok := m.nodes[e.Node.Name]; ok {
|
|
||||||
level.Info(logger).Log("msg", "node is no longer ready", "node", e.Node)
|
|
||||||
diff = true
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
switch e.Type {
|
switch e.Type {
|
||||||
case AddEvent:
|
case AddEvent:
|
||||||
fallthrough
|
fallthrough
|
||||||
@ -296,7 +292,6 @@ func (m *Mesh) syncNodes(e *NodeEvent) {
|
|||||||
delete(m.nodes, e.Node.Name)
|
delete(m.nodes, e.Node.Name)
|
||||||
diff = true
|
diff = true
|
||||||
}
|
}
|
||||||
}
|
|
||||||
m.mu.Unlock()
|
m.mu.Unlock()
|
||||||
if diff {
|
if diff {
|
||||||
level.Info(logger).Log("node", e.Node)
|
level.Info(logger).Log("node", e.Node)
|
||||||
@ -312,14 +307,10 @@ func (m *Mesh) syncPeers(e *PeerEvent) {
|
|||||||
// Peers are indexed by public key.
|
// Peers are indexed by public key.
|
||||||
key := string(e.Peer.PublicKey)
|
key := string(e.Peer.PublicKey)
|
||||||
if !e.Peer.Ready() {
|
if !e.Peer.Ready() {
|
||||||
level.Debug(logger).Log("msg", "received incomplete peer", "peer", e.Peer)
|
// Trace non ready peer with their presence in the mesh.
|
||||||
// An existing peer is no longer valid
|
_, ok := m.peers[key]
|
||||||
// so remove it from the mesh.
|
level.Debug(logger).Log("msg", "received non ready peer", "peer", e.Peer, "in-mesh", ok)
|
||||||
if _, ok := m.peers[key]; ok {
|
|
||||||
level.Info(logger).Log("msg", "peer is no longer ready", "peer", e.Peer)
|
|
||||||
diff = true
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
switch e.Type {
|
switch e.Type {
|
||||||
case AddEvent:
|
case AddEvent:
|
||||||
fallthrough
|
fallthrough
|
||||||
@ -336,7 +327,6 @@ func (m *Mesh) syncPeers(e *PeerEvent) {
|
|||||||
delete(m.peers, key)
|
delete(m.peers, key)
|
||||||
diff = true
|
diff = true
|
||||||
}
|
}
|
||||||
}
|
|
||||||
m.mu.Unlock()
|
m.mu.Unlock()
|
||||||
if diff {
|
if diff {
|
||||||
level.Info(logger).Log("peer", e.Peer)
|
level.Info(logger).Log("peer", e.Peer)
|
||||||
|
Loading…
Reference in New Issue
Block a user