From 100a9f15b87e5d40105c69f3c1e2e16c8492b65b Mon Sep 17 00:00:00 2001 From: benbierens Date: Fri, 22 Sep 2023 07:58:08 +0200 Subject: [PATCH] Downloads container log when codex contract deployment fails. --- .../CodexContractsPlugin.cs | 4 +-- .../CodexContractsStarter.cs | 34 +++++++++++++++---- .../CoreInterfaceExtensions.cs | 2 +- 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/ProjectPlugins/CodexContractsPlugin/CodexContractsPlugin.cs b/ProjectPlugins/CodexContractsPlugin/CodexContractsPlugin.cs index 5c03e33..b2e9a16 100644 --- a/ProjectPlugins/CodexContractsPlugin/CodexContractsPlugin.cs +++ b/ProjectPlugins/CodexContractsPlugin/CodexContractsPlugin.cs @@ -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) diff --git a/ProjectPlugins/CodexContractsPlugin/CodexContractsStarter.cs b/ProjectPlugins/CodexContractsPlugin/CodexContractsStarter.cs index cc314b7..f9f8839 100644 --- a/ProjectPlugins/CodexContractsPlugin/CodexContractsStarter.cs +++ b/ProjectPlugins/CodexContractsPlugin/CodexContractsStarter.cs @@ -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); diff --git a/ProjectPlugins/CodexContractsPlugin/CoreInterfaceExtensions.cs b/ProjectPlugins/CodexContractsPlugin/CoreInterfaceExtensions.cs index d2c3355..609216a 100644 --- a/ProjectPlugins/CodexContractsPlugin/CoreInterfaceExtensions.cs +++ b/ProjectPlugins/CodexContractsPlugin/CoreInterfaceExtensions.cs @@ -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)