From 8e4d43b73b346c6f2d9bc54f08fa8aeca5b6557b Mon Sep 17 00:00:00 2001 From: benbierens Date: Mon, 16 Oct 2023 11:19:57 +0200 Subject: [PATCH] Adds start and finished times to deployment json. --- ProjectPlugins/CodexPlugin/CodexAccess.cs | 1 + ProjectPlugins/CodexPlugin/CodexDeployment.cs | 8 ++-- Tools/CodexNetDeployer/Deployer.cs | 39 +++++++++++++++++-- 3 files changed, 41 insertions(+), 7 deletions(-) diff --git a/ProjectPlugins/CodexPlugin/CodexAccess.cs b/ProjectPlugins/CodexPlugin/CodexAccess.cs index 681dcf1..48ffb08 100644 --- a/ProjectPlugins/CodexPlugin/CodexAccess.cs +++ b/ProjectPlugins/CodexPlugin/CodexAccess.cs @@ -116,6 +116,7 @@ namespace CodexPlugin var log = tools.GetLog(); var file = log.CreateSubfile(); log.Log($"Container {Container.Name} has crashed. Downloading crash log to '{file.FullFilename}'..."); + file.Write($"Container Crash Log for {Container.Name}."); using var reader = new StreamReader(crashLog); var line = reader.ReadLine(); diff --git a/ProjectPlugins/CodexPlugin/CodexDeployment.cs b/ProjectPlugins/CodexPlugin/CodexDeployment.cs index 6dbf961..b44c6d2 100644 --- a/ProjectPlugins/CodexPlugin/CodexDeployment.cs +++ b/ProjectPlugins/CodexPlugin/CodexDeployment.cs @@ -21,9 +21,10 @@ namespace CodexPlugin public class DeploymentMetadata { - public DeploymentMetadata(string kubeNamespace, int numberOfCodexNodes, int numberOfValidators, int storageQuotaMB, CodexLogLevel codexLogLevel, int initialTestTokens, int minPrice, int maxCollateral, int maxDuration, int blockTTL, int blockMI, int blockMN) + public DeploymentMetadata(DateTime startUtc, DateTime finishedUtc, string kubeNamespace, int numberOfCodexNodes, int numberOfValidators, int storageQuotaMB, CodexLogLevel codexLogLevel, int initialTestTokens, int minPrice, int maxCollateral, int maxDuration, int blockTTL, int blockMI, int blockMN) { - DeployDateTimeUtc = DateTime.UtcNow; + StartUtc = startUtc; + FinishedUtc = finishedUtc; KubeNamespace = kubeNamespace; NumberOfCodexNodes = numberOfCodexNodes; NumberOfValidators = numberOfValidators; @@ -38,7 +39,8 @@ namespace CodexPlugin BlockMN = blockMN; } - public DateTime DeployDateTimeUtc { get; } + public DateTime StartUtc { get; } + public DateTime FinishedUtc { get; } public string KubeNamespace { get; } public int NumberOfCodexNodes { get; } public int NumberOfValidators { get; } diff --git a/Tools/CodexNetDeployer/Deployer.cs b/Tools/CodexNetDeployer/Deployer.cs index 54f9a5c..796fca8 100644 --- a/Tools/CodexNetDeployer/Deployer.cs +++ b/Tools/CodexNetDeployer/Deployer.cs @@ -51,6 +51,7 @@ namespace CodexNetDeployer localCodexBuilder.Build(); Log("Initializing..."); + var startUtc = DateTime.UtcNow; var ci = entryPoint.CreateInterface(); Log("Deploying Geth instance..."); @@ -78,7 +79,7 @@ namespace CodexNetDeployer CheckContainerRestarts(startResults); var codexContainers = startResults.Select(s => s.CodexNode.Container).ToArray(); - return new CodexDeployment(codexContainers, gethDeployment, metricsService, CreateMetadata()); + return new CodexDeployment(codexContainers, gethDeployment, metricsService, CreateMetadata(startUtc)); } private EntryPoint CreateEntryPoint(ILog log) @@ -87,11 +88,11 @@ namespace CodexNetDeployer var configuration = new KubernetesWorkflow.Configuration( kubeConfig, - operationTimeout: TimeSpan.FromSeconds(300), + operationTimeout: TimeSpan.FromMinutes(10), retryDelay: TimeSpan.FromSeconds(10), kubernetesNamespace: config.KubeNamespace); - var result = new EntryPoint(log, configuration, string.Empty); + var result = new EntryPoint(log, configuration, string.Empty, new FastHttpTimeSet()); configuration.Hooks = new K8sHook(config.TestsTypePodLabel, result.GetPluginMetadata()); return result; @@ -147,9 +148,11 @@ namespace CodexNetDeployer } } - private DeploymentMetadata CreateMetadata() + private DeploymentMetadata CreateMetadata(DateTime startUtc) { return new DeploymentMetadata( + startUtc: startUtc, + finishedUtc: DateTime.UtcNow, kubeNamespace: config.KubeNamespace, numberOfCodexNodes: config.NumberOfCodexNodes!.Value, numberOfValidators: config.NumberOfValidators!.Value, @@ -169,4 +172,32 @@ namespace CodexNetDeployer Console.WriteLine(msg); } } + + public class FastHttpTimeSet : ITimeSet + { + public TimeSpan HttpCallRetryDelay() + { + return TimeSpan.FromSeconds(2); + } + + public TimeSpan HttpCallRetryTime() + { + return TimeSpan.FromSeconds(2); + } + + public TimeSpan HttpCallTimeout() + { + return TimeSpan.FromSeconds(10); + } + + public TimeSpan K8sOperationTimeout() + { + return TimeSpan.FromMinutes(10); + } + + public TimeSpan WaitForK8sServiceDelay() + { + return TimeSpan.FromSeconds(30); + } + } }