mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 07:27:21 +00:00
Migrated pkg/proxy to structured logging (#104891)
* migrated service.go to structured logging * fixing capital letter in starting * migrated topology.go * migrated endpointslicecache.go * migrated endpoints.go * nit typo * nit plural to singular * fixed format * code formatting * resolving review comment for key ipFamily * resolving review comment for key endpoints.go * code formating * Converted Warningf to ErrorS, wherever applicable * included review changes * included review changes
This commit is contained in:
committed by
GitHub
parent
dea052ceba
commit
daf5af2917
@@ -246,7 +246,7 @@ func (ect *EndpointChangeTracker) Update(previous, current *v1.Endpoints) bool {
|
||||
delete(ect.lastChangeTriggerTimes, namespacedName)
|
||||
} else {
|
||||
for spn, eps := range change.current {
|
||||
klog.V(2).Infof("Service port %s updated: %d endpoints", spn, len(eps))
|
||||
klog.V(2).InfoS("Service port endpoints update", "servicePort", spn, "endpoints", len(eps))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,19 +259,19 @@ func (ect *EndpointChangeTracker) Update(previous, current *v1.Endpoints) bool {
|
||||
// If removeSlice is true, slice will be removed, otherwise it will be added or updated.
|
||||
func (ect *EndpointChangeTracker) EndpointSliceUpdate(endpointSlice *discovery.EndpointSlice, removeSlice bool) bool {
|
||||
if !supportedEndpointSliceAddressTypes.Has(string(endpointSlice.AddressType)) {
|
||||
klog.V(4).Infof("EndpointSlice address type not supported by kube-proxy: %s", endpointSlice.AddressType)
|
||||
klog.V(4).InfoS("EndpointSlice address type not supported by kube-proxy", "addressType", endpointSlice.AddressType)
|
||||
return false
|
||||
}
|
||||
|
||||
// This should never happen
|
||||
if endpointSlice == nil {
|
||||
klog.Error("Nil endpointSlice passed to EndpointSliceUpdate")
|
||||
klog.ErrorS(nil, "Nil endpointSlice passed to EndpointSliceUpdate")
|
||||
return false
|
||||
}
|
||||
|
||||
namespacedName, _, err := endpointSliceCacheKeys(endpointSlice)
|
||||
if err != nil {
|
||||
klog.Warningf("Error getting endpoint slice cache keys: %v", err)
|
||||
klog.InfoS("Error getting endpoint slice cache keys", "err", err)
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -349,8 +349,8 @@ func getLastChangeTriggerTime(annotations map[string]string) time.Time {
|
||||
}
|
||||
val, err := time.Parse(time.RFC3339Nano, annotations[v1.EndpointsLastChangeTriggerTime])
|
||||
if err != nil {
|
||||
klog.Warningf("Error while parsing EndpointsLastChangeTriggerTimeAnnotation: '%s'. Error is %v",
|
||||
annotations[v1.EndpointsLastChangeTriggerTime], err)
|
||||
klog.ErrorS(err, "Error while parsing EndpointsLastChangeTriggerTimeAnnotation",
|
||||
"value", annotations[v1.EndpointsLastChangeTriggerTime])
|
||||
// In case of error val = time.Zero, which is ignored in the upstream code.
|
||||
}
|
||||
return val
|
||||
@@ -419,7 +419,7 @@ func (ect *EndpointChangeTracker) endpointsToEndpointsMap(endpoints *v1.Endpoint
|
||||
for i := range ss.Ports {
|
||||
port := &ss.Ports[i]
|
||||
if port.Port == 0 {
|
||||
klog.Warningf("ignoring invalid endpoint port %s", port.Name)
|
||||
klog.ErrorS(nil, "Ignoring invalid endpoint port", "portName", port.Name)
|
||||
continue
|
||||
}
|
||||
svcPortName := ServicePortName{
|
||||
@@ -430,7 +430,7 @@ func (ect *EndpointChangeTracker) endpointsToEndpointsMap(endpoints *v1.Endpoint
|
||||
for i := range ss.Addresses {
|
||||
addr := &ss.Addresses[i]
|
||||
if addr.IP == "" {
|
||||
klog.Warningf("ignoring invalid endpoint port %s with empty host", port.Name)
|
||||
klog.ErrorS(nil, "Ignoring invalid endpoint port with empty host", "portName", port.Name)
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -466,7 +466,7 @@ func (ect *EndpointChangeTracker) endpointsToEndpointsMap(endpoints *v1.Endpoint
|
||||
}
|
||||
}
|
||||
|
||||
klog.V(3).Infof("Setting endpoints for %q to %+v", svcPortName, formatEndpointsList(endpointsMap[svcPortName]))
|
||||
klog.V(3).InfoS("Setting endpoints for service port", "portName", svcPortName, "endpoints", formatEndpointsList(endpointsMap[svcPortName]))
|
||||
}
|
||||
}
|
||||
return endpointsMap
|
||||
@@ -550,7 +550,7 @@ func detectStaleConnections(oldEndpointsMap, newEndpointsMap EndpointsMap, stale
|
||||
}
|
||||
}
|
||||
if stale {
|
||||
klog.V(4).Infof("Stale endpoint %v -> %v", svcPortName, ep.String())
|
||||
klog.V(4).InfoS("Stale endpoint", "portName", svcPortName, "endpoint", ep)
|
||||
*staleEndpoints = append(*staleEndpoints, ServiceEndpoint{Endpoint: ep.String(), ServicePortName: svcPortName})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user