From 7ecf94817a67e1eabe925fb82a1d99b4447b1f93 Mon Sep 17 00:00:00 2001 From: Andrew Azores Date: Tue, 10 Dec 2024 15:07:49 -0500 Subject: [PATCH] add endpoint conditions to node cryostat annotations --- .../KubeEndpointSlicesDiscovery.java | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/cryostat/discovery/KubeEndpointSlicesDiscovery.java b/src/main/java/io/cryostat/discovery/KubeEndpointSlicesDiscovery.java index 5e00aca60..0dc1bea27 100644 --- a/src/main/java/io/cryostat/discovery/KubeEndpointSlicesDiscovery.java +++ b/src/main/java/io/cryostat/discovery/KubeEndpointSlicesDiscovery.java @@ -45,6 +45,7 @@ import io.fabric8.kubernetes.api.model.ObjectReference; import io.fabric8.kubernetes.api.model.OwnerReference; import io.fabric8.kubernetes.api.model.discovery.v1.Endpoint; +import io.fabric8.kubernetes.api.model.discovery.v1.EndpointConditions; import io.fabric8.kubernetes.api.model.discovery.v1.EndpointPort; import io.fabric8.kubernetes.api.model.discovery.v1.EndpointSlice; import io.fabric8.kubernetes.client.KubernetesClient; @@ -235,7 +236,8 @@ List tuplesFromEndpoints(EndpointSlice slice) { queryForNode(ref.getNamespace(), ref.getName(), ref.getKind()) .getLeft(), addr, - port)); + port, + endpoint.getConditions())); } } } @@ -602,12 +604,19 @@ private class TargetTuple { HasMetadata obj; String addr; EndpointPort port; - - TargetTuple(ObjectReference objRef, HasMetadata obj, String addr, EndpointPort port) { + EndpointConditions conditions; + + TargetTuple( + ObjectReference objRef, + HasMetadata obj, + String addr, + EndpointPort port, + EndpointConditions conditions) { this.objRef = objRef; this.obj = obj; this.addr = addr; this.port = port; + this.conditions = conditions; } public Target toTarget() { @@ -640,7 +649,15 @@ public Target toTarget() { "NAMESPACE", objRef.getNamespace(), isPod ? "POD_NAME" : "OBJECT_NAME", - objRef.getName())); + objRef.getName(), + "CONDITION_READY", + String.valueOf(Boolean.TRUE.equals(conditions.getReady())), + "CONDITION_SERVING", + String.valueOf( + Boolean.TRUE.equals(conditions.getServing())), + "CONDITION_TERMINATING", + String.valueOf( + Boolean.TRUE.equals(conditions.getTerminating())))); return target; } catch (Exception e) {