From 073f0d86a1436eba66e260f11582c335cb8dad08 Mon Sep 17 00:00:00 2001 From: benbierens Date: Tue, 7 Nov 2023 16:02:09 +0100 Subject: [PATCH] Cleans up runnerLocationUtils. --- .../KubernetesWorkflow/RunnerLocationUtils.cs | 44 +------------------ 1 file changed, 2 insertions(+), 42 deletions(-) diff --git a/Framework/KubernetesWorkflow/RunnerLocationUtils.cs b/Framework/KubernetesWorkflow/RunnerLocationUtils.cs index 75676ab..9caa1ea 100644 --- a/Framework/KubernetesWorkflow/RunnerLocationUtils.cs +++ b/Framework/KubernetesWorkflow/RunnerLocationUtils.cs @@ -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; - } } }