Skip to content

Commit

Permalink
Fix confusing logging when receiving gossip from unknown (#5706)
Browse files Browse the repository at this point in the history
  • Loading branch information
ismaelhamed authored Mar 5, 2022
1 parent 4db81c1 commit 2bbc58c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
15 changes: 7 additions & 8 deletions src/core/Akka.Cluster/ClusterDaemon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1797,11 +1797,10 @@ public void Quarantined(UniqueAddress node)
public void ReceiveGossipStatus(GossipStatus status)
{
var from = status.From;
if (!LatestGossip.Overview.Reachability.IsReachable(SelfUniqueAddress, from))
if(!LatestGossip.HasMember(from))
_cluster.LogInfo("Ignoring received gossip status from unknown [{0}]", from);
else if (!LatestGossip.IsReachable(SelfUniqueAddress, from))
_cluster.LogInfo("Ignoring received gossip status from unreachable [{0}]", from);
else if (LatestGossip.Members.All(m => !m.UniqueAddress.Equals(from)))
_cluster.LogInfo("Cluster Node [{0}] - Ignoring received gossip status from unknown [{1}]",
_cluster.SelfAddress, from);
else
{
var comparison = status.Version.CompareTo(LatestGossip.Version);
Expand Down Expand Up @@ -1870,14 +1869,14 @@ public ReceiveGossipType ReceiveGossip(GossipEnvelope envelope)
from.Address, envelope.To);
return ReceiveGossipType.Ignored;
}
if (!localGossip.Overview.Reachability.IsReachable(SelfUniqueAddress, from))
if (!localGossip.HasMember(from))
{
_cluster.LogInfo("Ignoring received gossip from unreachable [{0}]", from);
_cluster.LogInfo("Ignoring received gossip from unknown [{0}]", from);
return ReceiveGossipType.Ignored;
}
if (localGossip.Members.All(m => !m.UniqueAddress.Equals(from)))
if (!localGossip.IsReachable(SelfUniqueAddress, from))
{
_cluster.LogInfo("Cluster Node [{0}] - Ignoring received gossip from unknown [{1}]", _cluster.SelfAddress, from);
_cluster.LogInfo("Ignoring received gossip from unreachable [{0}]", from);
return ReceiveGossipType.Ignored;
}
if (remoteGossip.Members.All(m => !m.UniqueAddress.Equals(SelfUniqueAddress)))
Expand Down
17 changes: 16 additions & 1 deletion src/core/Akka.Cluster/Gossip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,21 @@ public bool IsSingletonCluster
get { return _members.Count == 1; }
}

/// <summary>
/// Returns `true` if <paramref name="fromAddress"/> should be able to reach <paramref name="toAddress"/>
/// based on the unreachability data.
/// </summary>
/// <param name="fromAddress">TBD</param>
/// <param name="toAddress">TBD</param>
public bool IsReachable(UniqueAddress fromAddress, UniqueAddress toAddress)
{
if (!HasMember(toAddress))
return false;

// as it looks for specific unreachable entires for the node pair we don't have to filter on team
return Overview.Reachability.IsReachable(fromAddress, toAddress);
}

/// <summary>
/// TBD
/// </summary>
Expand Down Expand Up @@ -415,7 +430,7 @@ public GossipOverview Copy(ImmutableHashSet<UniqueAddress> seen = null, Reachabi
/// TBD
/// </summary>
public Reachability Reachability { get { return _reachability; } }

/// <inheritdoc/>
public override string ToString() => $"GossipOverview(seen=[{string.Join(", ", Seen)}], reachability={Reachability})";
}
Expand Down

0 comments on commit 2bbc58c

Please sign in to comment.