|
34 | 34 | import eu.openanalytics.containerproxy.model.runtime.ProxyStartupLog; |
35 | 35 | import eu.openanalytics.containerproxy.model.runtime.runtimevalues.BackendContainerNameKey; |
36 | 36 | import eu.openanalytics.containerproxy.model.runtime.runtimevalues.ContainerImageKey; |
| 37 | +import eu.openanalytics.containerproxy.model.runtime.runtimevalues.ContainerIndexKey; |
37 | 38 | import eu.openanalytics.containerproxy.model.runtime.runtimevalues.InstanceIdKey; |
38 | 39 | import eu.openanalytics.containerproxy.model.runtime.runtimevalues.ProxiedAppKey; |
| 40 | +import eu.openanalytics.containerproxy.model.runtime.runtimevalues.ProxyIdKey; |
39 | 41 | import eu.openanalytics.containerproxy.model.runtime.runtimevalues.RuntimeValue; |
40 | 42 | import eu.openanalytics.containerproxy.model.runtime.runtimevalues.RuntimeValueKey; |
41 | 43 | import eu.openanalytics.containerproxy.model.runtime.runtimevalues.RuntimeValueKeyRegistry; |
@@ -368,7 +370,7 @@ public Proxy startContainer(Authentication user, Container initialContainer, Con |
368 | 370 | .withApiVersion(apiVersion) |
369 | 371 | .withKind("Service") |
370 | 372 | .withNewMetadata() |
371 | | - .withName("sp-service-" + containerId) |
| 373 | + .withName(getServiceName(proxy, initialContainer)) |
372 | 374 | .withLabels(serviceLabels) |
373 | 375 | .endMetadata() |
374 | 376 | .withNewSpec() |
@@ -637,7 +639,7 @@ protected void doStopProxy(Proxy proxy) { |
637 | 639 |
|
638 | 640 | if (!isUseInternalNetwork()) { |
639 | 641 | // delete service when not using internal network |
640 | | - Service service = kubeClient.services().inNamespace(podInfo.get().getFirst()).withName(getServiceName(container)).get(); |
| 642 | + Service service = kubeClient.services().inNamespace(podInfo.get().getFirst()).withName(getServiceName(proxy, container)).get(); |
641 | 643 | if (service != null) { |
642 | 644 | kubeClient.resource(service).withGracePeriod(0).delete(); |
643 | 645 | } |
@@ -729,9 +731,12 @@ public List<ExistingContainerInfo> scanExistingContainers() { |
729 | 731 | continue; |
730 | 732 | } |
731 | 733 |
|
| 734 | + String proxyId = runtimeValues.get(ProxyIdKey.inst).getObject(); |
| 735 | + Integer containerIndex = runtimeValues.get(ContainerIndexKey.inst).getObject(); |
| 736 | + |
732 | 737 | Map<Integer, Integer> portBindings = new HashMap<>(); |
733 | 738 | if (!isUseInternalNetwork()) { |
734 | | - Service service = kubeClient.services().inNamespace(namespace).withName("sp-service-" + containerId).get(); |
| 739 | + Service service = kubeClient.services().inNamespace(namespace).withName("sp-service-" + proxyId + "-" + containerIndex).get(); |
735 | 740 | if (service == null) { |
736 | 741 | log.warn("Ignoring container {} because it has no associated service", containerId); |
737 | 742 | continue; |
@@ -783,8 +788,8 @@ private Optional<Pair<String, String>> getPodInfo(Container container) { |
783 | 788 | return Optional.of(Pair.of(tmp[0], tmp[1])); |
784 | 789 | } |
785 | 790 |
|
786 | | - private String getServiceName(Container container) { |
787 | | - return "sp-service-" + container.getId(); |
| 791 | + private String getServiceName(Proxy proxy, Container container) { |
| 792 | + return "sp-service-" + proxy.getId() + "-" + container.getIndex(); |
788 | 793 | } |
789 | 794 |
|
790 | 795 | private Optional<Pod> getPod(Container container) { |
|
0 commit comments