Adds codex debug-info to deployment json. Needed for bootstrapping later on.
This commit is contained in:
parent
dc0edce251
commit
14e8222dfe
|
@ -6,9 +6,9 @@ namespace CodexPlugin
|
||||||
{
|
{
|
||||||
public class CodexDeployment
|
public class CodexDeployment
|
||||||
{
|
{
|
||||||
public CodexDeployment(RunningContainer[] codexContainers, GethDeployment gethDeployment, CodexContractsDeployment codexContractsDeployment, RunningContainer? prometheusContainer, RunningContainer? discordBotContainer, DeploymentMetadata metadata)
|
public CodexDeployment(CodexInstance[] codexInstances, GethDeployment gethDeployment, CodexContractsDeployment codexContractsDeployment, RunningContainer? prometheusContainer, RunningContainer? discordBotContainer, DeploymentMetadata metadata)
|
||||||
{
|
{
|
||||||
CodexContainers = codexContainers;
|
CodexInstances = codexInstances;
|
||||||
GethDeployment = gethDeployment;
|
GethDeployment = gethDeployment;
|
||||||
CodexContractsDeployment = codexContractsDeployment;
|
CodexContractsDeployment = codexContractsDeployment;
|
||||||
PrometheusContainer = prometheusContainer;
|
PrometheusContainer = prometheusContainer;
|
||||||
|
@ -16,7 +16,7 @@ namespace CodexPlugin
|
||||||
Metadata = metadata;
|
Metadata = metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RunningContainer[] CodexContainers { get; }
|
public CodexInstance[] CodexInstances { get; }
|
||||||
public GethDeployment GethDeployment { get; }
|
public GethDeployment GethDeployment { get; }
|
||||||
public CodexContractsDeployment CodexContractsDeployment { get; }
|
public CodexContractsDeployment CodexContractsDeployment { get; }
|
||||||
public RunningContainer? PrometheusContainer { get; }
|
public RunningContainer? PrometheusContainer { get; }
|
||||||
|
@ -24,6 +24,18 @@ namespace CodexPlugin
|
||||||
public DeploymentMetadata Metadata { get; }
|
public DeploymentMetadata Metadata { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class CodexInstance
|
||||||
|
{
|
||||||
|
public CodexInstance(RunningContainer container, CodexDebugResponse info)
|
||||||
|
{
|
||||||
|
Container = container;
|
||||||
|
Info = info;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RunningContainer Container { get; }
|
||||||
|
public CodexDebugResponse Info { get; }
|
||||||
|
}
|
||||||
|
|
||||||
public class DeploymentMetadata
|
public class DeploymentMetadata
|
||||||
{
|
{
|
||||||
public DeploymentMetadata(string name, 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)
|
public DeploymentMetadata(string name, 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)
|
||||||
|
|
|
@ -247,9 +247,9 @@ namespace ContinuousTests
|
||||||
private RunningContainer[] SelectRandomContainers()
|
private RunningContainer[] SelectRandomContainers()
|
||||||
{
|
{
|
||||||
var number = handle.Test.RequiredNumberOfNodes;
|
var number = handle.Test.RequiredNumberOfNodes;
|
||||||
if (number == -1) return config.CodexDeployment.CodexContainers;
|
var containers = config.CodexDeployment.CodexInstances.Select(i => i.Container).ToList();
|
||||||
|
if (number == -1) return containers.ToArray();
|
||||||
|
|
||||||
var containers = config.CodexDeployment.CodexContainers.ToList();
|
|
||||||
var result = new RunningContainer[number];
|
var result = new RunningContainer[number];
|
||||||
for (var i = 0; i < number; i++)
|
for (var i = 0; i < number; i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -39,8 +39,9 @@ namespace ContinuousTests
|
||||||
{
|
{
|
||||||
log.Log("");
|
log.Log("");
|
||||||
var deployment = config.CodexDeployment;
|
var deployment = config.CodexDeployment;
|
||||||
foreach (var container in deployment.CodexContainers)
|
foreach (var instance in deployment.CodexInstances)
|
||||||
{
|
{
|
||||||
|
var container = instance.Container;
|
||||||
log.Log($"Codex environment variables for '{container.Name}':");
|
log.Log($"Codex environment variables for '{container.Name}':");
|
||||||
log.Log($"Pod name: {container.Pod.PodInfo.Name} - Deployment name: {container.Pod.DeploymentName}");
|
log.Log($"Pod name: {container.Pod.PodInfo.Name} - Deployment name: {container.Pod.DeploymentName}");
|
||||||
var codexVars = container.Recipe.EnvVars;
|
var codexVars = container.Recipe.EnvVars;
|
||||||
|
@ -81,7 +82,7 @@ namespace ContinuousTests
|
||||||
|
|
||||||
private void CheckCodexNodes(BaseLog log, Configuration config)
|
private void CheckCodexNodes(BaseLog log, Configuration config)
|
||||||
{
|
{
|
||||||
var nodes = entryPoint.CreateInterface().WrapCodexContainers(config.CodexDeployment.CodexContainers);
|
var nodes = entryPoint.CreateInterface().WrapCodexContainers(config.CodexDeployment.CodexInstances.Select(i => i.Container).ToArray());
|
||||||
var pass = true;
|
var pass = true;
|
||||||
foreach (var n in nodes)
|
foreach (var n in nodes)
|
||||||
{
|
{
|
||||||
|
@ -166,9 +167,9 @@ namespace ContinuousTests
|
||||||
{
|
{
|
||||||
errors.Add($"Test '{test.Name}' requires {test.RequiredNumberOfNodes} nodes. Test must require > 0 nodes, or -1 to select all nodes.");
|
errors.Add($"Test '{test.Name}' requires {test.RequiredNumberOfNodes} nodes. Test must require > 0 nodes, or -1 to select all nodes.");
|
||||||
}
|
}
|
||||||
else if (test.RequiredNumberOfNodes > config.CodexDeployment.CodexContainers.Length)
|
else if (test.RequiredNumberOfNodes > config.CodexDeployment.CodexInstances.Length)
|
||||||
{
|
{
|
||||||
errors.Add($"Test '{test.Name}' requires {test.RequiredNumberOfNodes} nodes. Deployment only has {config.CodexDeployment.CodexContainers.Length}");
|
errors.Add($"Test '{test.Name}' requires {test.RequiredNumberOfNodes} nodes. Deployment only has {config.CodexDeployment.CodexInstances.Length}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,26 +80,11 @@ namespace CodexNetDeployer
|
||||||
CheckPeerConnectivity(startResults);
|
CheckPeerConnectivity(startResults);
|
||||||
CheckContainerRestarts(startResults);
|
CheckContainerRestarts(startResults);
|
||||||
|
|
||||||
var codexContainers = startResults.Select(s => s.CodexNode.Container).ToArray();
|
var codexInstances = CreateCodexInstances(startResults);
|
||||||
|
|
||||||
var discordBotContainer = DeployDiscordBot(ci);
|
var discordBotContainer = DeployDiscordBot(ci);
|
||||||
|
|
||||||
return new CodexDeployment(codexContainers, gethDeployment, contractsDeployment, metricsService, discordBotContainer, CreateMetadata(startUtc));
|
return new CodexDeployment(codexInstances, gethDeployment, contractsDeployment, metricsService, discordBotContainer, CreateMetadata(startUtc));
|
||||||
}
|
|
||||||
|
|
||||||
private RunningContainer? DeployDiscordBot(CoreInterface ci)
|
|
||||||
{
|
|
||||||
if (!config.DeployDiscordBot) return null;
|
|
||||||
Log("Deploying Discord bot...");
|
|
||||||
|
|
||||||
var rc = ci.DeployCodexDiscordBot(new DiscordBotStartupConfig(
|
|
||||||
name: "discordbot-" + config.DeploymentName,
|
|
||||||
token: config.DiscordBotToken,
|
|
||||||
serverName: config.DiscordBotServerName,
|
|
||||||
adminRoleName: config.DiscordBotAdminRoleName));
|
|
||||||
|
|
||||||
Log("Discord bot deployed.");
|
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private EntryPoint CreateEntryPoint(ILog log)
|
private EntryPoint CreateEntryPoint(ILog log)
|
||||||
|
@ -135,6 +120,21 @@ namespace CodexNetDeployer
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private RunningContainer? DeployDiscordBot(CoreInterface ci)
|
||||||
|
{
|
||||||
|
if (!config.DeployDiscordBot) return null;
|
||||||
|
Log("Deploying Discord bot...");
|
||||||
|
|
||||||
|
var rc = ci.DeployCodexDiscordBot(new DiscordBotStartupConfig(
|
||||||
|
name: "discordbot-" + config.DeploymentName,
|
||||||
|
token: config.DiscordBotToken,
|
||||||
|
serverName: config.DiscordBotServerName,
|
||||||
|
adminRoleName: config.DiscordBotAdminRoleName));
|
||||||
|
|
||||||
|
Log("Discord bot deployed.");
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
private RunningContainer? StartMetricsService(CoreInterface ci, List<CodexNodeStartResult> startResults)
|
private RunningContainer? StartMetricsService(CoreInterface ci, List<CodexNodeStartResult> startResults)
|
||||||
{
|
{
|
||||||
if (!config.MetricsScraper) return null;
|
if (!config.MetricsScraper) return null;
|
||||||
|
@ -148,6 +148,16 @@ namespace CodexNetDeployer
|
||||||
return runningContainer;
|
return runningContainer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private CodexInstance[] CreateCodexInstances(List<CodexNodeStartResult> startResults)
|
||||||
|
{
|
||||||
|
return startResults.Select(r => CreateCodexInstance(r.CodexNode)).ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
private CodexInstance CreateCodexInstance(ICodexNode node)
|
||||||
|
{
|
||||||
|
return new CodexInstance(node.Container, node.GetDebugInfo());
|
||||||
|
}
|
||||||
|
|
||||||
private string? GetKubeConfig(string kubeConfigFile)
|
private string? GetKubeConfig(string kubeConfigFile)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(kubeConfigFile) || kubeConfigFile.ToLowerInvariant() == "null") return null;
|
if (string.IsNullOrEmpty(kubeConfigFile) || kubeConfigFile.ToLowerInvariant() == "null") return null;
|
||||||
|
|
Loading…
Reference in New Issue