Cleans up runnerLocationUtils.
This commit is contained in:
parent
ec6c987ef9
commit
073f0d86a1
|
@ -1,7 +1,4 @@
|
|||
using Logging;
|
||||
using System.Net.NetworkInformation;
|
||||
|
||||
namespace KubernetesWorkflow
|
||||
namespace KubernetesWorkflow
|
||||
{
|
||||
internal enum RunnerLocation
|
||||
{
|
||||
|
@ -21,7 +18,7 @@ namespace KubernetesWorkflow
|
|||
return location;
|
||||
}
|
||||
|
||||
private static void DetermineRunnerLocation()//ILog log, PodInfo info, K8sCluster cluster)
|
||||
private static void DetermineRunnerLocation()
|
||||
{
|
||||
if (location != RunnerLocation.Unknown) return;
|
||||
|
||||
|
@ -37,42 +34,5 @@ namespace KubernetesWorkflow
|
|||
location = RunnerLocation.InternalToCluster;
|
||||
}
|
||||
}
|
||||
|
||||
private static RunnerLocation PingForLocation(PodInfo podInfo, K8sCluster cluster)
|
||||
{
|
||||
if (PingHost(podInfo.Ip))
|
||||
{
|
||||
return RunnerLocation.InternalToCluster;
|
||||
}
|
||||
|
||||
if (PingHost(Format(cluster.HostAddress)))
|
||||
{
|
||||
return RunnerLocation.ExternalToCluster;
|
||||
}
|
||||
|
||||
throw new Exception("Unable to determine location relative to kubernetes cluster.");
|
||||
}
|
||||
|
||||
private static string Format(string host)
|
||||
{
|
||||
return host
|
||||
.Replace("http://", "")
|
||||
.Replace("https://", "");
|
||||
}
|
||||
|
||||
private static bool PingHost(string host)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var pinger = new Ping();
|
||||
PingReply reply = pinger.Send(host);
|
||||
return reply.Status == IPStatus.Success;
|
||||
}
|
||||
catch (PingException)
|
||||
{
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue