diff --git a/Framework/KubernetesWorkflow/ContainerRecipe.cs b/Framework/KubernetesWorkflow/ContainerRecipe.cs index 772ff20..6bac0ff 100644 --- a/Framework/KubernetesWorkflow/ContainerRecipe.cs +++ b/Framework/KubernetesWorkflow/ContainerRecipe.cs @@ -24,6 +24,8 @@ { Name = $"ctnr{Number}"; } + + if (exposedPorts.Any(p => string.IsNullOrEmpty(p.Tag))) throw new Exception("Port tags are required for all exposed ports."); } public string Name { get; } diff --git a/Framework/KubernetesWorkflow/ContainerRecipeFactory.cs b/Framework/KubernetesWorkflow/ContainerRecipeFactory.cs index 8d19398..6e50a1b 100644 --- a/Framework/KubernetesWorkflow/ContainerRecipeFactory.cs +++ b/Framework/KubernetesWorkflow/ContainerRecipeFactory.cs @@ -50,12 +50,12 @@ namespace KubernetesWorkflow protected int Index { get; private set; } = 0; protected abstract void Initialize(StartupConfig config); - protected Port AddExposedPort(string tag = "") + protected Port AddExposedPort(string tag) { return AddExposedPort(factory.CreatePort(tag)); } - protected Port AddExposedPort(int number, string tag = "") + protected Port AddExposedPort(int number, string tag) { return AddExposedPort(factory.CreatePort(number, tag)); } @@ -67,7 +67,7 @@ namespace KubernetesWorkflow return p; } - protected void AddExposedPortAndVar(string name, string tag = "") + protected void AddExposedPortAndVar(string name, string tag) { AddEnvVar(name, AddExposedPort(tag)); } diff --git a/ProjectPlugins/CodexPlugin/CodexContainerRecipe.cs b/ProjectPlugins/CodexPlugin/CodexContainerRecipe.cs index 905041a..867b9bf 100644 --- a/ProjectPlugins/CodexPlugin/CodexContainerRecipe.cs +++ b/ProjectPlugins/CodexPlugin/CodexContainerRecipe.cs @@ -8,8 +8,10 @@ namespace CodexPlugin private readonly MarketplaceStarter marketplaceStarter = new MarketplaceStarter(); private const string DefaultDockerImage = "codexstorage/nim-codex:latest-dist-tests"; - public const string MetricsPortTag = "metrics_port"; - public const string DiscoveryPortTag = "discovery-port"; + public const string ApiPortTag = "codex_api_port"; + public const string ListenPortTag = "codex_listen_port"; + public const string MetricsPortTag = "codex_metrics_port"; + public const string DiscoveryPortTag = "codex_discovery_port"; // Used by tests for time-constraint assertions. public static readonly TimeSpan MaxUploadTimePerMegabyte = TimeSpan.FromSeconds(2.0); @@ -27,7 +29,7 @@ namespace CodexPlugin var config = startupConfig.Get(); - AddExposedPortAndVar("CODEX_API_PORT"); + AddExposedPortAndVar("CODEX_API_PORT", ApiPortTag); AddEnvVar("CODEX_API_BINDADDR", "0.0.0.0"); var dataDir = $"datadir{ContainerNumber}"; @@ -40,7 +42,7 @@ namespace CodexPlugin // This makes the node announce itself to its local (pod) IP address. AddEnvVar("NAT_IP_AUTO", "true"); - var listenPort = AddExposedPort(); + var listenPort = AddExposedPort(ListenPortTag); AddEnvVar("CODEX_LISTEN_ADDRS", $"/ip4/0.0.0.0/tcp/{listenPort.Number}"); if (!string.IsNullOrEmpty(config.BootstrapSpr)) diff --git a/ProjectPlugins/MetricsPlugin/PrometheusContainerRecipe.cs b/ProjectPlugins/MetricsPlugin/PrometheusContainerRecipe.cs index 26b9b48..2696915 100644 --- a/ProjectPlugins/MetricsPlugin/PrometheusContainerRecipe.cs +++ b/ProjectPlugins/MetricsPlugin/PrometheusContainerRecipe.cs @@ -7,11 +7,13 @@ namespace MetricsPlugin public override string AppName => "prometheus"; public override string Image => "codexstorage/dist-tests-prometheus:latest"; + public const string PortTag = "prometheus_port_tag"; + protected override void Initialize(StartupConfig startupConfig) { var config = startupConfig.Get(); - AddExposedPortAndVar("PROM_PORT"); + AddExposedPortAndVar("PROM_PORT", PortTag); AddEnvVar("PROM_CONFIG", config.PrometheusConfigBase64); } }