diff --git a/src/main/java/io/cryostat/discovery/KubeApiDiscovery.java b/src/main/java/io/cryostat/discovery/KubeApiDiscovery.java index 08f011b9e..3f47ffdaf 100644 --- a/src/main/java/io/cryostat/discovery/KubeApiDiscovery.java +++ b/src/main/java/io/cryostat/discovery/KubeApiDiscovery.java @@ -227,7 +227,14 @@ List tuplesFromEndpoints(Endpoints endpoints) { for (EndpointSubset subset : endpoints.getSubsets()) { for (EndpointPort port : subset.getPorts()) { for (EndpointAddress addr : subset.getAddresses()) { - tts.add(new TargetTuple(addr.getTargetRef(), addr, port)); + var ref = addr.getTargetRef(); + tts.add( + new TargetTuple( + ref, + queryForNode(ref.getNamespace(), ref.getName(), ref.getKind()) + .getLeft(), + addr, + port)); } } } @@ -584,11 +591,14 @@ static EndpointDiscoveryEvent from( private class TargetTuple { ObjectReference objRef; + HasMetadata obj; EndpointAddress addr; EndpointPort port; - TargetTuple(ObjectReference objRef, EndpointAddress addr, EndpointPort port) { + TargetTuple( + ObjectReference objRef, HasMetadata obj, EndpointAddress addr, EndpointPort port) { this.objRef = objRef; + this.obj = obj; this.addr = addr; this.port = port; } @@ -613,11 +623,6 @@ public Target toTarget() { "/jndi/rmi://" + host + ':' + port.getPort() + "/jmxrmi"); URI connectUrl = URI.create(jmxUrl.toString()); - Pair pair = - queryForNode(namespace, objRef.getName(), objRef.getKind()); - - HasMetadata obj = pair.getLeft(); - Target target = new Target(); target.activeRecordings = new ArrayList<>(); target.connectUrl = connectUrl;