From 959022fdca08039710b5eeaff60032de9b4c8618 Mon Sep 17 00:00:00 2001 From: Aaron U'Ren Date: Fri, 1 Mar 2024 10:44:42 -0600 Subject: [PATCH] feat(NSC): add endpoint statuses to internal struct Add isReady, isServing, and isTerminating to internal EndpointSlice struct so that downstream consumers have more information about the service to make decisions later on. --- .../proxy/network_services_controller.go | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/pkg/controllers/proxy/network_services_controller.go b/pkg/controllers/proxy/network_services_controller.go index 82566cc8..f30a0621 100644 --- a/pkg/controllers/proxy/network_services_controller.go +++ b/pkg/controllers/proxy/network_services_controller.go @@ -214,11 +214,14 @@ type serviceInfoMap map[string]*serviceInfo // internal representation of endpoints type endpointSliceInfo struct { - ip string - port int - isLocal bool - isIPv4 bool - isIPv6 bool + ip string + port int + isLocal bool + isIPv4 bool + isIPv6 bool + isReady bool + isServing bool + isTerminating bool } // map of all endpoints, with unique service id(namespace name, service name, port) as key @@ -1105,11 +1108,14 @@ func (nsc *NetworkServicesController) buildEndpointSliceInfo() endpointSliceInfo for _, addr := range ep.Addresses { isLocal := ep.NodeName != nil && *ep.NodeName == nsc.nodeHostName endpoints = append(endpoints, endpointSliceInfo{ - ip: addr, - port: int(*port.Port), - isLocal: isLocal, - isIPv4: isIPv4, - isIPv6: isIPv6, + ip: addr, + port: int(*port.Port), + isLocal: isLocal, + isIPv4: isIPv4, + isIPv6: isIPv6, + isReady: ep.Conditions.Ready != nil && *ep.Conditions.Ready, + isServing: ep.Conditions.Serving != nil && *ep.Conditions.Serving, + isTerminating: ep.Conditions.Terminating != nil && *ep.Conditions.Terminating, }) } endpointsMap[svcID] = shuffle(endpoints)