mirror of
https://github.com/kubernetes/kubernetes.git
synced 2026-10-28 15:05:03 +08:00
proxy: consolidate EndpointSlice logging
Moves endpoint logging from endpointslicecache.go down to endpointschangetracker.go merge and unmerge methods to be consistent with service updates, without losing endpoint tracking information. Change-Id: I09369a4b32929d8df4b520921d74223090872a60
This commit is contained in:
2 files changed
+17
-12
No files matched your search
@@ -237,17 +237,33 @@ func (em EndpointsMap) Update(ect *EndpointsChangeTracker) UpdateEndpointsMapRes
|
||||
// Merge ensures that the current EndpointsMap contains all <service, endpoints> pairs from the EndpointsMap passed in.
|
||||
func (em EndpointsMap) merge(other EndpointsMap) {
|
||||
for svcPortName := range other {
|
||||
em[svcPortName] = other[svcPortName]
|
||||
epList := other[svcPortName]
|
||||
if _, exists := em[svcPortName]; !exists {
|
||||
klog.V(3).InfoS("Adding new service endpoints", "portName", svcPortName, "endpoints", formatEndpointsList(epList))
|
||||
} else {
|
||||
klog.V(3).InfoS("Updating existing service endpoints", "portName", svcPortName, "endpoints", formatEndpointsList(epList))
|
||||
}
|
||||
em[svcPortName] = epList
|
||||
}
|
||||
}
|
||||
|
||||
// Unmerge removes the <service, endpoints> pairs from the current EndpointsMap which are contained in the EndpointsMap passed in.
|
||||
func (em EndpointsMap) unmerge(other EndpointsMap) {
|
||||
for svcPortName := range other {
|
||||
klog.V(3).InfoS("Removing service endpoints", "portName", svcPortName)
|
||||
delete(em, svcPortName)
|
||||
}
|
||||
}
|
||||
|
||||
// formatEndpointsList returns a string list converted from an endpoints list.
|
||||
func formatEndpointsList(endpoints []Endpoint) []string {
|
||||
var formattedList []string
|
||||
for _, ep := range endpoints {
|
||||
formattedList = append(formattedList, ep.String())
|
||||
}
|
||||
return formattedList
|
||||
}
|
||||
|
||||
// getLocalEndpointIPs returns endpoints IPs if given endpoint is local - local means the endpoint is running in same host as kube-proxy.
|
||||
func (em EndpointsMap) getLocalReadyEndpointIPs() map[types.NamespacedName]sets.Set[string] {
|
||||
localIPs := make(map[types.NamespacedName]sets.Set[string])
|
||||
|
||||
@@ -301,23 +301,12 @@ func endpointsMapFromEndpointInfo(endpointInfoBySP map[ServicePortName]map[strin
|
||||
}
|
||||
// Ensure endpoints are always returned in the same order to simplify diffing.
|
||||
sort.Sort(byEndpoint(endpointsMap[svcPortName]))
|
||||
|
||||
klog.V(3).InfoS("Setting endpoints for service port name", "portName", svcPortName, "endpoints", formatEndpointsList(endpointsMap[svcPortName]))
|
||||
}
|
||||
}
|
||||
|
||||
return endpointsMap
|
||||
}
|
||||
|
||||
// formatEndpointsList returns a string list converted from an endpoints list.
|
||||
func formatEndpointsList(endpoints []Endpoint) []string {
|
||||
var formattedList []string
|
||||
for _, ep := range endpoints {
|
||||
formattedList = append(formattedList, ep.String())
|
||||
}
|
||||
return formattedList
|
||||
}
|
||||
|
||||
// endpointSliceCacheKeys returns cache keys used for a given EndpointSlice.
|
||||
func endpointSliceCacheKeys(endpointSlice *discovery.EndpointSlice) (types.NamespacedName, string, error) {
|
||||
var err error
|
||||
|
||||
Reference in new issue
Block a user