Unknown runner location option.

This commit is contained in:
benbierens 2023-11-07 12:42:01 +01:00
parent ea66b5b408
commit 3e500e8346
No known key found for this signature in database
GPG Key ID: FE44815D96D0A1AA
3 changed files with 10 additions and 6 deletions

View File

@ -1,25 +1,25 @@
using Logging; using Logging;
using System.Net.NetworkInformation; using System.Net.NetworkInformation;
using Utils;
namespace KubernetesWorkflow namespace KubernetesWorkflow
{ {
internal enum RunnerLocation internal enum RunnerLocation
{ {
Unknown,
ExternalToCluster, ExternalToCluster,
InternalToCluster, InternalToCluster,
} }
internal static class RunnerLocationUtils internal static class RunnerLocationUtils
{ {
private static RunnerLocation? knownLocation = null; private static RunnerLocation knownLocation = RunnerLocation.Unknown;
internal static RunnerLocation DetermineRunnerLocation(ILog log, PodInfo info, K8sCluster cluster) internal static RunnerLocation DetermineRunnerLocation(ILog log, PodInfo info, K8sCluster cluster)
{ {
if (knownLocation != null) return knownLocation.Value; if (knownLocation != RunnerLocation.Unknown) return knownLocation;
knownLocation = PingForLocation(info, cluster); knownLocation = PingForLocation(info, cluster);
log.Log("Runner location set to: " + knownLocation); log.Log("Runner location set to: " + knownLocation);
return knownLocation.Value; return knownLocation;
} }
private static RunnerLocation PingForLocation(PodInfo podInfo, K8sCluster cluster) private static RunnerLocation PingForLocation(PodInfo podInfo, K8sCluster cluster)

View File

@ -58,10 +58,14 @@ namespace KubernetesWorkflow
{ {
select = addresses.Single(a => a.IsInteral); select = addresses.Single(a => a.IsInteral);
} }
else else if (location == RunnerLocation.ExternalToCluster)
{ {
select = addresses.Single(a => !a.IsInteral); select = addresses.Single(a => !a.IsInteral);
} }
else
{
throw new Exception("Running location not known.");
}
log.Log($"Container '{Name}' selected for tag '{portTag}' address: '{select}'"); log.Log($"Container '{Name}' selected for tag '{portTag}' address: '{select}'");
return select.Address; return select.Address;

View File

@ -27,7 +27,7 @@ namespace CodexNetDeployer
public CodexNodeStartResult? Start(int i) public CodexNodeStartResult? Start(int i)
{ {
var name = GetCodexContainerName(i); var name = GetCodexContainerName(i);
Console.Write($" - {i} ({name})"); Console.Write($" - {i} ({name})\t");
Console.CursorLeft = 30; Console.CursorLeft = 30;
ICodexNode? codexNode = null; ICodexNode? codexNode = null;