Skip to content

Commit 03d19f0

Browse files
committed
Fix #36178: show node name in admin panel
1 parent c4d18d9 commit 03d19f0

4 files changed

Lines changed: 54 additions & 0 deletions

File tree

src/main/java/eu/openanalytics/containerproxy/backend/docker/DockerSwarmBackend.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import eu.openanalytics.containerproxy.model.runtime.runtimevalues.BackendContainerNameKey;
3333
import eu.openanalytics.containerproxy.model.runtime.runtimevalues.ContainerImageKey;
3434
import eu.openanalytics.containerproxy.model.runtime.runtimevalues.InstanceIdKey;
35+
import eu.openanalytics.containerproxy.model.runtime.runtimevalues.NodeNameKey;
3536
import eu.openanalytics.containerproxy.model.runtime.runtimevalues.RuntimeValue;
3637
import eu.openanalytics.containerproxy.model.runtime.runtimevalues.RuntimeValueKey;
3738
import eu.openanalytics.containerproxy.model.runtime.runtimevalues.UserIdKey;
@@ -220,6 +221,7 @@ public Proxy startContainer(Authentication user, Container initialContainer, Con
220221
.stream().findAny().orElseThrow(() -> new IllegalStateException("Swarm service has no tasks"));
221222
if (serviceTask.status().containerStatus() != null && serviceTask.status().state().equals("running")) {
222223
rContainerBuilder.id(serviceTask.status().containerStatus().containerId());
224+
rContainerBuilder.addRuntimeValue(new RuntimeValue(NodeNameKey.inst, serviceTask.nodeId()), false);
223225
return Retrying.SUCCESS;
224226
} else if (!STARTING_STATES.contains(serviceTask.status().state())) {
225227
slog.warn(proxy, "Docker Swarm container failed: container not running, state reported by docker: " + toJson(serviceTask.status()));

src/main/java/eu/openanalytics/containerproxy/backend/kubernetes/KubernetesBackend.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import eu.openanalytics.containerproxy.model.runtime.runtimevalues.ContainerImageKey;
3939
import eu.openanalytics.containerproxy.model.runtime.runtimevalues.ContainerIndexKey;
4040
import eu.openanalytics.containerproxy.model.runtime.runtimevalues.InstanceIdKey;
41+
import eu.openanalytics.containerproxy.model.runtime.runtimevalues.NodeNameKey;
4142
import eu.openanalytics.containerproxy.model.runtime.runtimevalues.ProxiedAppKey;
4243
import eu.openanalytics.containerproxy.model.runtime.runtimevalues.ProxyIdKey;
4344
import eu.openanalytics.containerproxy.model.runtime.runtimevalues.RuntimeValue;
@@ -398,6 +399,7 @@ public Proxy startContainer(Authentication user, Container initialContainer, Con
398399
Pod pod = kubeClient.resource(startedPod).get();
399400

400401
parseKubernetesEvents(spec.getIndex(), pod, proxyStartupLogBuilder);
402+
rContainerBuilder.addRuntimeValue(new RuntimeValue(NodeNameKey.inst, pod.getSpec().getNodeName()), false);
401403

402404
Service service;
403405
Map<Integer, Integer> portBindings = new HashMap<>();
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* ContainerProxy
3+
*
4+
* Copyright (C) 2016-2026 Open Analytics
5+
*
6+
* ===========================================================================
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the Apache License as published by
10+
* The Apache Software Foundation, either version 2 of the License, or
11+
* (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* Apache License for more details.
17+
*
18+
* You should have received a copy of the Apache License
19+
* along with this program. If not, see <http://www.apache.org/licenses/>
20+
*/
21+
package eu.openanalytics.containerproxy.model.runtime.runtimevalues;
22+
23+
public class NodeNameKey extends RuntimeValueKey<String> {
24+
25+
public final static NodeNameKey inst = new NodeNameKey();
26+
27+
private NodeNameKey() {
28+
super("openanalytics.eu/sp-node-name",
29+
"SHINYPROXY_NODE_NAME",
30+
false,
31+
false,
32+
false,
33+
false, // important: may not be exposed in API for security
34+
false,
35+
true,
36+
String.class);
37+
}
38+
39+
@Override
40+
public String deserializeFromString(String value) {
41+
return value;
42+
}
43+
44+
@Override
45+
public String serializeToString(String value) {
46+
return value;
47+
}
48+
49+
}

src/main/java/eu/openanalytics/containerproxy/model/runtime/runtimevalues/RuntimeValueKeyRegistry.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public class RuntimeValueKeyRegistry {
5454
addRuntimeValueKey(TargetIdKey.inst);
5555
addRuntimeValueKey(CacheHeadersModeKey.inst);
5656
addRuntimeValueKey(LanguageKey.inst);
57+
addRuntimeValueKey(NodeNameKey.inst);
5758
}
5859

5960
public static void addRuntimeValueKey(RuntimeValueKey<?> key) {

0 commit comments

Comments
 (0)