Skip to content

Commit 2bbc58c

Browse files
authored
Fix confusing logging when receiving gossip from unknown (#5706)
1 parent 4db81c1 commit 2bbc58c

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

src/core/Akka.Cluster/ClusterDaemon.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1797,11 +1797,10 @@ public void Quarantined(UniqueAddress node)
17971797
public void ReceiveGossipStatus(GossipStatus status)
17981798
{
17991799
var from = status.From;
1800-
if (!LatestGossip.Overview.Reachability.IsReachable(SelfUniqueAddress, from))
1800+
if(!LatestGossip.HasMember(from))
1801+
_cluster.LogInfo("Ignoring received gossip status from unknown [{0}]", from);
1802+
else if (!LatestGossip.IsReachable(SelfUniqueAddress, from))
18011803
_cluster.LogInfo("Ignoring received gossip status from unreachable [{0}]", from);
1802-
else if (LatestGossip.Members.All(m => !m.UniqueAddress.Equals(from)))
1803-
_cluster.LogInfo("Cluster Node [{0}] - Ignoring received gossip status from unknown [{1}]",
1804-
_cluster.SelfAddress, from);
18051804
else
18061805
{
18071806
var comparison = status.Version.CompareTo(LatestGossip.Version);
@@ -1870,14 +1869,14 @@ public ReceiveGossipType ReceiveGossip(GossipEnvelope envelope)
18701869
from.Address, envelope.To);
18711870
return ReceiveGossipType.Ignored;
18721871
}
1873-
if (!localGossip.Overview.Reachability.IsReachable(SelfUniqueAddress, from))
1872+
if (!localGossip.HasMember(from))
18741873
{
1875-
_cluster.LogInfo("Ignoring received gossip from unreachable [{0}]", from);
1874+
_cluster.LogInfo("Ignoring received gossip from unknown [{0}]", from);
18761875
return ReceiveGossipType.Ignored;
18771876
}
1878-
if (localGossip.Members.All(m => !m.UniqueAddress.Equals(from)))
1877+
if (!localGossip.IsReachable(SelfUniqueAddress, from))
18791878
{
1880-
_cluster.LogInfo("Cluster Node [{0}] - Ignoring received gossip from unknown [{1}]", _cluster.SelfAddress, from);
1879+
_cluster.LogInfo("Ignoring received gossip from unreachable [{0}]", from);
18811880
return ReceiveGossipType.Ignored;
18821881
}
18831882
if (remoteGossip.Members.All(m => !m.UniqueAddress.Equals(SelfUniqueAddress)))

src/core/Akka.Cluster/Gossip.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,21 @@ public bool IsSingletonCluster
294294
get { return _members.Count == 1; }
295295
}
296296

297+
/// <summary>
298+
/// Returns `true` if <paramref name="fromAddress"/> should be able to reach <paramref name="toAddress"/>
299+
/// based on the unreachability data.
300+
/// </summary>
301+
/// <param name="fromAddress">TBD</param>
302+
/// <param name="toAddress">TBD</param>
303+
public bool IsReachable(UniqueAddress fromAddress, UniqueAddress toAddress)
304+
{
305+
if (!HasMember(toAddress))
306+
return false;
307+
308+
// as it looks for specific unreachable entires for the node pair we don't have to filter on team
309+
return Overview.Reachability.IsReachable(fromAddress, toAddress);
310+
}
311+
297312
/// <summary>
298313
/// TBD
299314
/// </summary>
@@ -415,7 +430,7 @@ public GossipOverview Copy(ImmutableHashSet<UniqueAddress> seen = null, Reachabi
415430
/// TBD
416431
/// </summary>
417432
public Reachability Reachability { get { return _reachability; } }
418-
433+
419434
/// <inheritdoc/>
420435
public override string ToString() => $"GossipOverview(seen=[{string.Join(", ", Seen)}], reachability={Reachability})";
421436
}

0 commit comments

Comments
 (0)