Cleans up runnerLocationUtils.
This commit is contained in:
parent
ec6c987ef9
commit
073f0d86a1
|
@ -1,7 +1,4 @@
|
||||||
using Logging;
|
namespace KubernetesWorkflow
|
||||||
using System.Net.NetworkInformation;
|
|
||||||
|
|
||||||
namespace KubernetesWorkflow
|
|
||||||
{
|
{
|
||||||
internal enum RunnerLocation
|
internal enum RunnerLocation
|
||||||
{
|
{
|
||||||
|
@ -21,7 +18,7 @@ namespace KubernetesWorkflow
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void DetermineRunnerLocation()//ILog log, PodInfo info, K8sCluster cluster)
|
private static void DetermineRunnerLocation()
|
||||||
{
|
{
|
||||||
if (location != RunnerLocation.Unknown) return;
|
if (location != RunnerLocation.Unknown) return;
|
||||||
|
|
||||||
|
@ -37,42 +34,5 @@ namespace KubernetesWorkflow
|
||||||
location = RunnerLocation.InternalToCluster;
|
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