Skip to content

Commit

Permalink
#1838: Disabled ARP lookups: HostingManager.CheckForIPConflictsAsync()
Browse files Browse the repository at this point in the history
  • Loading branch information
jefflill committed Aug 8, 2023
1 parent 01118fa commit 17150c2
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions Lib/Neon.Kube/Hosting/HostingManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,17 @@ protected async Task<string> CheckForIPConflictsAsync(ClusterDefinition clusterD
{
Covenant.Requires<ArgumentNullException>(clusterDefinition != null, nameof(clusterDefinition));

// We're to send ICMP pings to all node IP addresses and keep track of
// any responses (indicating conflcits) and then read the local machine's
// $todo(jefflill):
//
// The ARP cache lookups need more testing and will be disabled until then.
// We've seen situations when deploying a neon-desktop cluster when the
// cluster IP is reported as being in use. This may also impact other
// clusters as well.
//
// https://github.com/nforgeio/neonKUBE/issues/1838

// We're going to send ICMP pings to all node IP addresses and keep track
// of any responses (indicating conflcits) and then read the local machine's
// ARP table looking for any conflicts there.
//
// NOTE: It's possible for machines to have ICMP ping disabled so we
Expand All @@ -258,6 +267,7 @@ protected async Task<string> CheckForIPConflictsAsync(ClusterDefinition clusterD

var nodeConflicts = new Dictionary<string, NodeDefinition>(StringComparer.InvariantCultureIgnoreCase);

#if TODO
using (var pinger = new Pinger())
{
await Parallel.ForEachAsync(clusterDefinition.NodeDefinitions.Values, new ParallelOptions() { MaxDegreeOfParallelism = 50 },
Expand Down Expand Up @@ -317,6 +327,25 @@ protected async Task<string> CheckForIPConflictsAsync(ClusterDefinition clusterD
nodeConflicts[nodeDefinition.Name] = nodeDefinition;
}
}
#endif
using (var pinger = new Pinger())
{
await Parallel.ForEachAsync(clusterDefinition.NodeDefinitions.Values, new ParallelOptions() { MaxDegreeOfParallelism = 50 },
async (nodeDefinition, cancellationToken) =>
{
var reply = await pinger.SendPingAsync(nodeDefinition.Address);
if (reply.Status == IPStatus.Success)
{
// We got a response.
lock (nodeConflicts)
{
nodeConflicts.Add(nodeDefinition.Name, nodeDefinition);
}
}
});
}

if (nodeConflicts.Count == 0)
{
Expand Down

0 comments on commit 17150c2

Please sign in to comment.