debugging address selection in cluster

This commit is contained in:
benbierens 2023-11-07 12:02:17 +01:00
parent 655f4895d0
commit ea66b5b408
No known key found for this signature in database
GPG Key ID: FE44815D96D0A1AA
8 changed files with 23 additions and 15 deletions

View File

@ -1,4 +1,5 @@
using Newtonsoft.Json;
using Logging;
using Newtonsoft.Json;
using Utils;
namespace KubernetesWorkflow
@ -46,20 +47,24 @@ namespace KubernetesWorkflow
[JsonIgnore]
public RunningContainers RunningContainers { get; internal set; } = null!;
public Address GetAddress(string portTag)
public Address GetAddress(ILog log, string portTag)
{
var addresses = Addresses.Where(a => a.PortTag == portTag).ToArray();
if (!addresses.Any()) throw new Exception("No addresses found for portTag: " + portTag);
var location = RunningContainers.StartResult.RunnerLocation;
ContainerAddress select = null!;
if (location == RunnerLocation.InternalToCluster)
{
return addresses.Single(a => a.IsInteral).Address;
select = addresses.Single(a => a.IsInteral);
}
else
{
return addresses.Single(a => !a.IsInteral).Address;
select = addresses.Single(a => !a.IsInteral);
}
log.Log($"Container '{Name}' selected for tag '{portTag}' address: '{select}'");
return select.Address;
}
public Address GetInternalAddress(string portTag)
@ -84,7 +89,8 @@ namespace KubernetesWorkflow
public override string ToString()
{
return $"{PortTag} -> '{Address}'";
var indicator = IsInteral ? "int" : "ext";
return $"{indicator} {PortTag} -> '{Address}'";
}
}

View File

@ -1,5 +1,6 @@
using GethPlugin;
using KubernetesWorkflow;
using Logging;
namespace CodexContractsPlugin
{
@ -17,7 +18,7 @@ namespace CodexContractsPlugin
{
var config = startupConfig.Get<CodexContractsContainerConfig>();
var address = config.GethNode.StartResult.Container.GetAddress(GethContainerRecipe.HttpPortTag);
var address = config.GethNode.StartResult.Container.GetAddress(new ConsoleLog(), GethContainerRecipe.HttpPortTag);
AddEnvVar("DISTTEST_NETWORK_URL", address.ToString());
AddEnvVar("HARDHAT_NETWORK", "codexdisttestnetwork");

View File

@ -115,7 +115,7 @@ namespace CodexPlugin
private Address GetAddress()
{
return Container.GetAddress(CodexContainerRecipe.ApiPortTag);
return Container.GetAddress(tools.GetLog(), CodexContainerRecipe.ApiPortTag);
}
private void CheckContainerCrashed(HttpClient client)

View File

@ -71,7 +71,7 @@ namespace GethPlugin
private NethereumInteraction StartInteraction()
{
var address = StartResult.Container.GetAddress(GethContainerRecipe.HttpPortTag);
var address = StartResult.Container.GetAddress(log, GethContainerRecipe.HttpPortTag);
var account = StartResult.Account;
var creator = new NethereumInteractionCreator(log, address.Host, address.Port, account.PrivateKey);

View File

@ -13,8 +13,8 @@ namespace MetricsPlugin
public MetricsQuery(IPluginTools tools, RunningContainer runningContainer)
{
RunningContainer = runningContainer;
http = tools.CreateHttp(RunningContainer.GetAddress(PrometheusContainerRecipe.PortTag), "api/v1");
log = tools.GetLog();
http = tools.CreateHttp(RunningContainer.GetAddress(log, PrometheusContainerRecipe.PortTag), "api/v1");
}
public RunningContainer RunningContainer { get; }
@ -122,7 +122,7 @@ namespace MetricsPlugin
private string GetInstanceNameForNode(IMetricsScrapeTarget target)
{
return ScrapeTargetHelper.FormatTarget(target);
return ScrapeTargetHelper.FormatTarget(log, target);
}
private string GetInstanceStringForNode(IMetricsScrapeTarget target)

View File

@ -1,5 +1,6 @@
using Core;
using KubernetesWorkflow;
using Logging;
using System.Text;
namespace MetricsPlugin
@ -68,15 +69,15 @@ namespace MetricsPlugin
private string FormatTarget(IMetricsScrapeTarget target)
{
return ScrapeTargetHelper.FormatTarget(target);
return ScrapeTargetHelper.FormatTarget(tools.GetLog(), target);
}
}
public static class ScrapeTargetHelper
{
public static string FormatTarget(IMetricsScrapeTarget target)
public static string FormatTarget(ILog log, IMetricsScrapeTarget target)
{
var a = target.Container.GetAddress(target.MetricsPortTag);
var a = target.Container.GetAddress(log, target.MetricsPortTag);
var host = a.Host.Replace("http://", "").Replace("https://", "");
return $"{host}:{a.Port}";
}

View File

@ -92,7 +92,7 @@ namespace ContinuousTests
{
cancelToken.ThrowIfCancellationRequested();
var address = n.Container.GetAddress(CodexContainerRecipe.ApiPortTag);
var address = n.Container.GetAddress(log, CodexContainerRecipe.ApiPortTag);
log.Log($"Checking {n.Container.Name} @ '{address}'...");
if (EnsureOnline(log, n))

View File

@ -14,7 +14,7 @@ namespace DistTestCore
{
kubeConfigFile = GetNullableEnvVarOrDefault("KUBECONFIG", null);
logPath = GetEnvVarOrDefault("LOGPATH", "CodexTestLogs");
logDebug = GetEnvVarOrDefault("LOGDEBUG", "false").ToLowerInvariant() == "true";
logDebug = true;// GetEnvVarOrDefault("LOGDEBUG", "false").ToLowerInvariant() == "true";
dataFilesPath = GetEnvVarOrDefault("DATAFILEPATH", "TestDataFiles");
}