Creates internal service ports for external ports from container recipe.

This commit is contained in:
benbierens 2023-11-06 16:38:32 +01:00
parent 8d0b3feff7
commit ad88560061
No known key found for this signature in database
GPG Key ID: FE44815D96D0A1AA
2 changed files with 11 additions and 6 deletions

View File

@ -647,7 +647,7 @@ namespace KubernetesWorkflow
private RunningService? CreateInternalService(ContainerRecipe[] recipes) private RunningService? CreateInternalService(ContainerRecipe[] recipes)
{ {
return CreateService(recipes, r => r.InternalPorts, "ClusterIP", "int"); return CreateService(recipes, r => r.InternalPorts.Concat(r.ExposedPorts).ToArray(), "ClusterIP", "int");
} }
private RunningService? CreateExternalService(ContainerRecipe[] recipes) private RunningService? CreateExternalService(ContainerRecipe[] recipes)

View File

@ -48,13 +48,18 @@ namespace KubernetesWorkflow
public Address GetAddress(string portTag) public Address GetAddress(string portTag)
{ {
var containerAddress = Addresses.Single(a => a.PortTag == portTag); var addresses = Addresses.Where(a => a.PortTag == portTag).ToArray();
if (containerAddress.IsInteral && RunningContainers.StartResult.RunnerLocation == RunnerLocation.ExternalToCluster) if (!addresses.Any()) throw new Exception("No addresses found for portTag: " + portTag);
var location = RunningContainers.StartResult.RunnerLocation;
if (location == RunnerLocation.InternalToCluster)
{ {
throw new Exception("Attempt to access a container address created from an Internal port, " + return addresses.Single(a => a.IsInteral).Address;
"while runner is located external to the cluster."); }
else
{
return addresses.Single(a => !a.IsInteral).Address;
} }
return containerAddress.Address;
} }
public Address GetInternalAddress(string portTag) public Address GetInternalAddress(string portTag)