Determine runner location by pinging pod IP.

This commit is contained in:
benbierens 2023-08-11 09:09:03 +02:00
parent fff02656b7
commit 5d92b99926
No known key found for this signature in database
GPG Key ID: FE44815D96D0A1AA
1 changed files with 6 additions and 7 deletions

View File

@ -13,6 +13,7 @@ namespace DistTestCore
private readonly string dataFilesPath;
private readonly CodexLogLevel codexLogLevel;
private readonly string k8sNamespacePrefix;
private RunnerLocation? runnerLocation = null;
public Configuration()
{
@ -59,8 +60,6 @@ namespace DistTestCore
return codexLogLevel;
}
private RunnerLocation? runnerLocation = null;
public Address GetAddress(RunningContainer container)
{
if (runnerLocation == null)
@ -96,7 +95,7 @@ namespace DistTestCore
InternalToCluster,
}
public class RunnerLocationUtils
public static class RunnerLocationUtils
{
private static bool alreadyDidThat = false;
@ -108,11 +107,11 @@ namespace DistTestCore
if (alreadyDidThat) throw new Exception("We already did that.");
alreadyDidThat = true;
if (PingHost(container.ClusterInternalAddress))
if (PingHost(container.Pod.PodInfo.Ip))
{
return RunnerLocation.InternalToCluster;
}
if (PingHost(container.ClusterExternalAddress))
if (PingHost(Format(container.ClusterExternalAddress)))
{
return RunnerLocation.ExternalToCluster;
}
@ -127,12 +126,12 @@ namespace DistTestCore
.Replace("https://", "");
}
private static bool PingHost(Address host)
private static bool PingHost(string host)
{
try
{
using var pinger = new Ping();
PingReply reply = pinger.Send(Format(host));
PingReply reply = pinger.Send(host);
return reply.Status == IPStatus.Success;
}
catch (PingException)