From 3e500e834674919e7120f2652b7e38aea80896c3 Mon Sep 17 00:00:00 2001 From: benbierens Date: Tue, 7 Nov 2023 12:42:01 +0100 Subject: [PATCH] Unknown runner location option. --- Framework/KubernetesWorkflow/RunnerLocationUtils.cs | 8 ++++---- Framework/KubernetesWorkflow/RunningContainers.cs | 6 +++++- Tools/CodexNetDeployer/CodexNodeStarter.cs | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Framework/KubernetesWorkflow/RunnerLocationUtils.cs b/Framework/KubernetesWorkflow/RunnerLocationUtils.cs index 293d5fd..429fc63 100644 --- a/Framework/KubernetesWorkflow/RunnerLocationUtils.cs +++ b/Framework/KubernetesWorkflow/RunnerLocationUtils.cs @@ -1,25 +1,25 @@ using Logging; using System.Net.NetworkInformation; -using Utils; namespace KubernetesWorkflow { internal enum RunnerLocation { + Unknown, ExternalToCluster, InternalToCluster, } 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) { - if (knownLocation != null) return knownLocation.Value; + if (knownLocation != RunnerLocation.Unknown) return knownLocation; knownLocation = PingForLocation(info, cluster); log.Log("Runner location set to: " + knownLocation); - return knownLocation.Value; + return knownLocation; } private static RunnerLocation PingForLocation(PodInfo podInfo, K8sCluster cluster) diff --git a/Framework/KubernetesWorkflow/RunningContainers.cs b/Framework/KubernetesWorkflow/RunningContainers.cs index 2a9a50e..619c636 100644 --- a/Framework/KubernetesWorkflow/RunningContainers.cs +++ b/Framework/KubernetesWorkflow/RunningContainers.cs @@ -58,10 +58,14 @@ namespace KubernetesWorkflow { select = addresses.Single(a => a.IsInteral); } - else + else if (location == RunnerLocation.ExternalToCluster) { select = addresses.Single(a => !a.IsInteral); } + else + { + throw new Exception("Running location not known."); + } log.Log($"Container '{Name}' selected for tag '{portTag}' address: '{select}'"); return select.Address; diff --git a/Tools/CodexNetDeployer/CodexNodeStarter.cs b/Tools/CodexNetDeployer/CodexNodeStarter.cs index 04cf2d0..e18720e 100644 --- a/Tools/CodexNetDeployer/CodexNodeStarter.cs +++ b/Tools/CodexNetDeployer/CodexNodeStarter.cs @@ -27,7 +27,7 @@ namespace CodexNetDeployer public CodexNodeStartResult? Start(int i) { var name = GetCodexContainerName(i); - Console.Write($" - {i} ({name})"); + Console.Write($" - {i} ({name})\t"); Console.CursorLeft = 30; ICodexNode? codexNode = null;