From e11a7d160045ef8d97bbb3439f4610672005d47c Mon Sep 17 00:00:00 2001 From: benbierens Date: Mon, 23 Oct 2023 10:19:52 +0200 Subject: [PATCH] Gives deployments a name. --- ProjectPlugins/CodexPlugin/CodexDeployment.cs | 4 +++- Tests/CodexContinuousTests/deploy-and-run.sh | 1 + Tools/BiblioTech/Commands/DeploymentsCommand.cs | 11 +++++++++-- Tools/BiblioTech/docker/docker-compose.yaml | 1 + Tools/CodexNetDeployer/Configuration.cs | 3 +++ Tools/CodexNetDeployer/Deployer.cs | 1 + Tools/CodexNetDeployer/deploy-continuous-testnet.sh | 1 + 7 files changed, 19 insertions(+), 3 deletions(-) diff --git a/ProjectPlugins/CodexPlugin/CodexDeployment.cs b/ProjectPlugins/CodexPlugin/CodexDeployment.cs index f63d8bb..b0b50c0 100644 --- a/ProjectPlugins/CodexPlugin/CodexDeployment.cs +++ b/ProjectPlugins/CodexPlugin/CodexDeployment.cs @@ -24,8 +24,9 @@ namespace CodexPlugin public class DeploymentMetadata { - 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) + 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) { + Name = name; StartUtc = startUtc; FinishedUtc = finishedUtc; KubeNamespace = kubeNamespace; @@ -42,6 +43,7 @@ namespace CodexPlugin BlockMN = blockMN; } + public string Name { get; } public DateTime StartUtc { get; } public DateTime FinishedUtc { get; } public string KubeNamespace { get; } diff --git a/Tests/CodexContinuousTests/deploy-and-run.sh b/Tests/CodexContinuousTests/deploy-and-run.sh index 1fa5037..dfc5e10 100644 --- a/Tests/CodexContinuousTests/deploy-and-run.sh +++ b/Tests/CodexContinuousTests/deploy-and-run.sh @@ -9,6 +9,7 @@ cd ../../Tools/CodexNetDeployer for i in $( seq 0 $replication) do dotnet run \ + --deploy-name=codex-continuous-$name-$i \ --kube-config=/opt/kubeconfig.yaml \ --kube-namespace=codex-continuous-$name-tests-$i \ --deploy-file=codex-deployment-$name-$i.json \ diff --git a/Tools/BiblioTech/Commands/DeploymentsCommand.cs b/Tools/BiblioTech/Commands/DeploymentsCommand.cs index a3cca79..50dc95f 100644 --- a/Tools/BiblioTech/Commands/DeploymentsCommand.cs +++ b/Tools/BiblioTech/Commands/DeploymentsCommand.cs @@ -1,4 +1,5 @@ -using Discord.WebSocket; +using CodexPlugin; +using Discord.WebSocket; namespace BiblioTech.Commands { @@ -25,7 +26,13 @@ namespace BiblioTech.Commands return; } - await command.FollowupAsync($"Deployments: {string.Join(", ", deployments.Select(d => d.Metadata.StartUtc.ToString("o")))}"); + await command.FollowupAsync($"Deployments: {string.Join(", ", deployments.Select(FormatDeployment))}"); + } + + private string FormatDeployment(CodexDeployment deployment) + { + var m = deployment.Metadata; + return $"{m.Name} ({m.StartUtc.ToString("o")})"; } } } diff --git a/Tools/BiblioTech/docker/docker-compose.yaml b/Tools/BiblioTech/docker/docker-compose.yaml index dae80e4..2eaff90 100644 --- a/Tools/BiblioTech/docker/docker-compose.yaml +++ b/Tools/BiblioTech/docker/docker-compose.yaml @@ -4,3 +4,4 @@ services: environment: - TOKEN=tokenplz - SERVERNAME=ThatBen's server + - ADMINROLE=adminers diff --git a/Tools/CodexNetDeployer/Configuration.cs b/Tools/CodexNetDeployer/Configuration.cs index 3a371cd..f37e342 100644 --- a/Tools/CodexNetDeployer/Configuration.cs +++ b/Tools/CodexNetDeployer/Configuration.cs @@ -8,6 +8,9 @@ namespace CodexNetDeployer public const int SecondsIn1Day = 24 * 60 * 60; public const int TenMinutes = 10 * 60; + [Uniform("deploy-name", "nm", "DEPLOYNAME", false, "Name of the deployment. (optional)")] + public string DeploymentName { get; set; } = "unnamed"; + [Uniform("kube-config", "kc", "KUBECONFIG", false, "Path to Kubeconfig file. Use 'null' (default) to use local cluster.")] public string KubeConfigFile { get; set; } = "null"; diff --git a/Tools/CodexNetDeployer/Deployer.cs b/Tools/CodexNetDeployer/Deployer.cs index 6dd3e6c..6aa0945 100644 --- a/Tools/CodexNetDeployer/Deployer.cs +++ b/Tools/CodexNetDeployer/Deployer.cs @@ -151,6 +151,7 @@ namespace CodexNetDeployer private DeploymentMetadata CreateMetadata(DateTime startUtc) { return new DeploymentMetadata( + name: config.DeploymentName, startUtc: startUtc, finishedUtc: DateTime.UtcNow, kubeNamespace: config.KubeNamespace, diff --git a/Tools/CodexNetDeployer/deploy-continuous-testnet.sh b/Tools/CodexNetDeployer/deploy-continuous-testnet.sh index 8036273..2fe63a5 100644 --- a/Tools/CodexNetDeployer/deploy-continuous-testnet.sh +++ b/Tools/CodexNetDeployer/deploy-continuous-testnet.sh @@ -1,4 +1,5 @@ dotnet run \ + --deploy-name=codex-continuous-test-deployment \ --kube-config=/opt/kubeconfig.yaml \ --kube-namespace=codex-continuous-tests \ --deploy-file=codex-deployment.json \