Skip to content

Commit

Permalink
feat(NSC): add / clarify log messages
Browse files Browse the repository at this point in the history
  • Loading branch information
aauren committed Jan 24, 2024
1 parent d757f49 commit d3cf4d1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 2 additions & 0 deletions pkg/controllers/proxy/network_services_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1025,6 +1025,7 @@ func (nsc *NetworkServicesController) buildEndpointSliceInfo() endpointSliceInfo
for _, obj := range nsc.epSliceLister.List() {
var isIPv4, isIPv6 bool
es := obj.(*discovery.EndpointSlice)
klog.V(2).Infof("Building endpoint info for EndpointSlice: %s/%s", es.Namespace, es.Name)
switch es.AddressType {
case discovery.AddressTypeIPv4:
isIPv4 = true
Expand Down Expand Up @@ -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
// it the same.
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
}

Expand Down
17 changes: 12 additions & 5 deletions pkg/controllers/proxy/service_endpoints_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ func (nsc *NetworkServicesController) setupClusterIPServices(serviceInfoMap serv
// node
err = nsc.ln.ipAddrAdd(dummyVipInterface, clusterIP.String(), nodeIP, true)
if err != nil {
// Not logging an error here because it was already logged in the ipAddrAdd function
continue
}

Expand All @@ -153,6 +154,7 @@ func (nsc *NetworkServicesController) setupClusterIPServices(serviceInfoMap serv
protocol, uint16(svc.port))
// We weren't able to create the IPVS service, so we won't be able to add endpoints to it
if svcID == "" {
// not logging an error here because it was already logged in the addIPVSService function
continue
}

Expand Down Expand Up @@ -191,12 +193,16 @@ func (nsc *NetworkServicesController) addEndpointsToIPVSService(endpoints []endp
family = v1.IPv6Protocol
}

if len(endpoints) < 1 {
klog.Infof("No endpoints detected for service VIP: %s, skipping adding endpoints...", vip)
}
for _, endpoint := range endpoints {
// Conditions on which to add an endpoint on this node:
// 1) Service is not a local service
// 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
if svc.local && !endpoint.isLocal {
klog.V(2).Info("service is local, but endpoint is not, continuing...")
continue
}
var syscallINET uint16
Expand Down Expand Up @@ -227,11 +233,11 @@ func (nsc *NetworkServicesController) addEndpointsToIPVSService(endpoints []endp
}
err := nsc.ln.ipvsAddServer(ipvsSvc, &dst)
if err != nil {
klog.Errorf(err.Error())
} else {
svcEndpointMap[svcID] = append(svcEndpointMap[svcID],
generateEndpointID(endpoint.ip, strconv.Itoa(endpoint.port)))
klog.Errorf("encountered error adding endpoint to service: %v", err)
continue
}
svcEndpointMap[svcID] = append(svcEndpointMap[svcID],
generateEndpointID(endpoint.ip, strconv.Itoa(endpoint.port)))
}
}

Expand Down Expand Up @@ -336,7 +342,8 @@ func (nsc *NetworkServicesController) setupExternalIPServices(serviceInfoMap ser
}
}
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
}

Expand Down

0 comments on commit d3cf4d1

Please sign in to comment.