Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix confusing logging when receiving gossip from unknown #5706

Merged
merged 1 commit into from
Mar 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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