Downloads container log when codex contract deployment fails.

This commit is contained in:
benbierens 2023-09-22 07:58:08 +02:00
parent d2854bb905
commit 100a9f15b8
No known key found for this signature in database
GPG Key ID: FE44815D96D0A1AA
3 changed files with 30 additions and 10 deletions

View File

@ -30,9 +30,9 @@ namespace CodexContractsPlugin
{
}
public CodexContractsDeployment DeployContracts(IGethNode gethNode)
public CodexContractsDeployment DeployContracts(CoreInterface ci, IGethNode gethNode)
{
return starter.Deploy(gethNode);
return starter.Deploy(ci, gethNode);
}
public ICodexContracts WrapDeploy(CodexContractsDeployment deployment)

View File

@ -2,6 +2,7 @@
using GethPlugin;
using KubernetesWorkflow;
using Logging;
using Nethereum.Contracts;
using Utils;
namespace CodexContractsPlugin
@ -15,17 +16,41 @@ namespace CodexContractsPlugin
this.tools = tools;
}
public CodexContractsDeployment Deploy(IGethNode gethNode)
public CodexContractsDeployment Deploy(CoreInterface ci, IGethNode gethNode)
{
Log("Deploying Codex SmartContracts...");
Log("Starting Codex SmartContracts container...");
var workflow = tools.CreateWorkflow();
var startupConfig = CreateStartupConfig(gethNode);
startupConfig.NameOverride = "codex-contracts";
var containers = workflow.Start(1, Location.Unspecified, new CodexContractsContainerRecipe(), startupConfig);
if (containers.Containers.Length != 1) throw new InvalidOperationException("Expected 1 Codex contracts container to be created. Test infra failure.");
var container = containers.Containers[0];
Log("Container started.");
try
{
return DeployContract(container, workflow, gethNode);
}
catch
{
Log("Failed to deploy contract.");
Log("Downloading Codex SmartContracts container log...");
ci.DownloadLog(container);
throw;
}
}
public ICodexContracts Wrap(CodexContractsDeployment deployment)
{
return new CodexContractsAccess(tools.GetLog(), deployment);
}
private CodexContractsDeployment DeployContract(RunningContainer container, IStartupWorkflow workflow, IGethNode gethNode)
{
Log("Deploying SmartContract...");
WaitUntil(() =>
{
var logHandler = new ContractsReadyLogHandler(tools.GetLog());
@ -50,11 +75,6 @@ namespace CodexContractsPlugin
return new CodexContractsDeployment(marketplaceAddress, abi, tokenAddress);
}
public ICodexContracts Wrap(CodexContractsDeployment deployment)
{
return new CodexContractsAccess(tools.GetLog(), deployment);
}
private void Log(string msg)
{
tools.GetLog().Log(msg);

View File

@ -7,7 +7,7 @@ namespace CodexContractsPlugin
{
public static CodexContractsDeployment DeployCodexContracts(this CoreInterface ci, IGethNode gethNode)
{
return Plugin(ci).DeployContracts(gethNode);
return Plugin(ci).DeployContracts(ci, gethNode);
}
public static ICodexContracts WrapCodexContractsDeployment(this CoreInterface ci, CodexContractsDeployment deployment)