feat(NSC): add / clarify log messages

This commit is contained in:
Aaron U'Ren 2024-01-08 16:17:55 -06:00 committed by Aaron U'Ren
parent d757f49d55
commit d3cf4d13a7
2 changed files with 14 additions and 5 deletions

View File

@ -1025,6 +1025,7 @@ func (nsc *NetworkServicesController) buildEndpointSliceInfo() endpointSliceInfo
for _, obj := range nsc.epSliceLister.List() { for _, obj := range nsc.epSliceLister.List() {
var isIPv4, isIPv6 bool var isIPv4, isIPv6 bool
es := obj.(*discovery.EndpointSlice) es := obj.(*discovery.EndpointSlice)
klog.V(2).Infof("Building endpoint info for EndpointSlice: %s/%s", es.Namespace, es.Name)
switch es.AddressType { switch es.AddressType {
case discovery.AddressTypeIPv4: case discovery.AddressTypeIPv4:
isIPv4 = true isIPv4 = true
@ -1073,6 +1074,7 @@ func (nsc *NetworkServicesController) buildEndpointSliceInfo() endpointSliceInfo
// changing this to .Serving which continues to include pods that are in Terminating state. For now we keep // changing this to .Serving which continues to include pods that are in Terminating state. For now we keep
// it the same. // it the same.
if ep.Conditions.Ready == nil || !*ep.Conditions.Ready { if ep.Conditions.Ready == nil || !*ep.Conditions.Ready {
klog.V(2).Infof("Endpoint (with addresses %s) does not have a ready status, skipping...", ep.Addresses)
continue continue
} }

View File

@ -145,6 +145,7 @@ func (nsc *NetworkServicesController) setupClusterIPServices(serviceInfoMap serv
// node // node
err = nsc.ln.ipAddrAdd(dummyVipInterface, clusterIP.String(), nodeIP, true) err = nsc.ln.ipAddrAdd(dummyVipInterface, clusterIP.String(), nodeIP, true)
if err != nil { if err != nil {
// Not logging an error here because it was already logged in the ipAddrAdd function
continue continue
} }
@ -153,6 +154,7 @@ func (nsc *NetworkServicesController) setupClusterIPServices(serviceInfoMap serv
protocol, uint16(svc.port)) protocol, uint16(svc.port))
// We weren't able to create the IPVS service, so we won't be able to add endpoints to it // We weren't able to create the IPVS service, so we won't be able to add endpoints to it
if svcID == "" { if svcID == "" {
// not logging an error here because it was already logged in the addIPVSService function
continue continue
} }
@ -191,12 +193,16 @@ func (nsc *NetworkServicesController) addEndpointsToIPVSService(endpoints []endp
family = v1.IPv6Protocol family = v1.IPv6Protocol
} }
if len(endpoints) < 1 {
klog.Infof("No endpoints detected for service VIP: %s, skipping adding endpoints...", vip)
}
for _, endpoint := range endpoints { for _, endpoint := range endpoints {
// Conditions on which to add an endpoint on this node: // Conditions on which to add an endpoint on this node:
// 1) Service is not a local service // 1) Service is not a local service
// 2) Service is a local service, but has no active endpoints on this node // 2) Service is a local service, but has no active endpoints on this node
// 3) Service is a local service, has active endpoints on this node, and this endpoint is one of them // 3) Service is a local service, has active endpoints on this node, and this endpoint is one of them
if svc.local && !endpoint.isLocal { if svc.local && !endpoint.isLocal {
klog.V(2).Info("service is local, but endpoint is not, continuing...")
continue continue
} }
var syscallINET uint16 var syscallINET uint16
@ -227,11 +233,11 @@ func (nsc *NetworkServicesController) addEndpointsToIPVSService(endpoints []endp
} }
err := nsc.ln.ipvsAddServer(ipvsSvc, &dst) err := nsc.ln.ipvsAddServer(ipvsSvc, &dst)
if err != nil { if err != nil {
klog.Errorf(err.Error()) klog.Errorf("encountered error adding endpoint to service: %v", err)
} else { continue
svcEndpointMap[svcID] = append(svcEndpointMap[svcID],
generateEndpointID(endpoint.ip, strconv.Itoa(endpoint.port)))
} }
svcEndpointMap[svcID] = append(svcEndpointMap[svcID],
generateEndpointID(endpoint.ip, strconv.Itoa(endpoint.port)))
} }
} }
@ -336,7 +342,8 @@ func (nsc *NetworkServicesController) setupExternalIPServices(serviceInfoMap ser
} }
} }
if !addrsFound { if !addrsFound {
klog.V(1).Infof("no IP addresses returned for external service %s:%s", svc.namespace, svc.name) klog.V(1).Infof("no external IP addresses returned for service %s:%s skipping...",
svc.namespace, svc.name)
continue continue
} }