attempt to fix contract deployment in testnet mode

This commit is contained in:
benbierens 2023-10-23 15:28:20 +02:00
parent b2b338d0a5
commit 2fae9505d6
No known key found for this signature in database
GPG Key ID: FE44815D96D0A1AA
6 changed files with 20 additions and 25 deletions

View File

@ -81,10 +81,6 @@ namespace KubernetesWorkflow
{
DeleteNamespace(ns);
}
foreach (var ns in namespaces)
{
WaitUntilNamespaceDeleted(ns);
}
}
public void DeleteNamespace()
@ -94,7 +90,6 @@ namespace KubernetesWorkflow
{
client.Run(c => c.DeleteNamespace(K8sNamespace, null, null, gracePeriodSeconds: 0));
}
WaitUntilNamespaceDeleted();
}
public void DeleteNamespace(string ns)
@ -645,16 +640,6 @@ namespace KubernetesWorkflow
WaitUntil(() => IsNamespaceOnline(K8sNamespace));
}
private void WaitUntilNamespaceDeleted()
{
WaitUntil(() => !IsNamespaceOnline(K8sNamespace));
}
private void WaitUntilNamespaceDeleted(string name)
{
WaitUntil(() => !IsNamespaceOnline(name));
}
private void WaitUntilDeploymentOnline(string deploymentName)
{
WaitUntil(() =>

View File

@ -29,7 +29,7 @@ namespace KubernetesWorkflow
foreach (var port in container.ContainerPorts)
{
if (PingHost(Format(port.ExternalAddress)))
if (port.ExternalAddress.IsValid() && PingHost(Format(port.ExternalAddress)))
{
return RunnerLocation.ExternalToCluster;
}

View File

@ -1,5 +1,4 @@
using Newtonsoft.Json;
using Utils;
using Utils;
namespace KubernetesWorkflow
{
@ -39,14 +38,19 @@ namespace KubernetesWorkflow
public Port[] ServicePorts { get; }
public ContainerPort[] ContainerPorts { get; }
public ContainerPort GetContainerPort(string portTag)
{
return ContainerPorts.Single(c => c.Port.Tag == portTag);
}
public Address GetAddress(string portTag)
{
var containerPort = ContainerPorts.Single(c => c.Port.Tag == portTag);
var containerPort = GetContainerPort(portTag);
if (RunnerLocationUtils.DetermineRunnerLocation(this) == RunnerLocation.InternalToCluster)
{
return containerPort.InternalAddress;
}
if (containerPort.ExternalAddress == Address.InvalidAddress) throw new Exception($"Getting address by tag {portTag} resulted in an invalid address.");
if (!containerPort.ExternalAddress.IsValid()) throw new Exception($"Getting address by tag {portTag} resulted in an invalid address.");
return containerPort.ExternalAddress;
}
}

View File

@ -152,7 +152,7 @@ namespace KubernetesWorkflow
{
result.Add(new ContainerPort(
internalPort,
Address.InvalidAddress,
new Address(string.Empty, 0),
GetContainerInternalAddress(internalPort)));
}
}

View File

@ -2,8 +2,6 @@
{
public class Address
{
public static readonly Address InvalidAddress = new Address(string.Empty, 0);
public Address(string host, int port)
{
Host = host;
@ -17,5 +15,10 @@
{
return $"{Host}:{Port}";
}
public bool IsValid()
{
return !string.IsNullOrEmpty(Host) && Port > 0;
}
}
}

View File

@ -1,4 +1,5 @@
using KubernetesWorkflow;
using GethPlugin;
using KubernetesWorkflow;
namespace CodexContractsPlugin
{
@ -16,8 +17,10 @@ namespace CodexContractsPlugin
{
var config = startupConfig.Get<CodexContractsContainerConfig>();
var containerPort = config.GethNode.StartResult.Container.GetContainerPort(GethContainerRecipe.HttpPortTag);
var ip = config.GethNode.StartResult.Container.Pod.PodInfo.Ip;
var port = config.GethNode.StartResult.HttpPort.Number;
var port = containerPort.InternalAddress.Port;
AddEnvVar("DISTTEST_NETWORK_URL", $"http://{ip}:{port}");
AddEnvVar("HARDHAT_NETWORK", "codexdisttestnetwork");