Skip to content

Commit

Permalink
feat(NSC): add endpoint statuses to internal struct
Browse files Browse the repository at this point in the history
Add isReady, isServing, and isTerminating to internal EndpointSlice
struct so that downstream consumers have more information about the
service to make decisions later on.
  • Loading branch information
aauren committed Mar 1, 2024
1 parent 16daa08 commit 959022f
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions pkg/controllers/proxy/network_services_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 959022f

Please sign in to comment.