Introduced additional log formatting to windows kubeproxy.

This commit is contained in:
Prince Pereira 2025-02-19 01:44:39 -08:00
parent e39571591d
commit 3d007532e0
2 changed files with 42 additions and 9 deletions

View File

@ -168,7 +168,7 @@ func (hns hns) getAllEndpointsByNetwork(networkName string) (map[string]*(endpoi
} }
endpointInfos[ep.IpConfigurations[1].IpAddress] = endpointDualstack endpointInfos[ep.IpConfigurations[1].IpAddress] = endpointDualstack
} }
klog.V(3).InfoS("Queried endpoints from network", "network", networkName) klog.V(3).InfoS("Queried endpoints from network", "network", networkName, "count", len(endpointInfos))
klog.V(5).InfoS("Queried endpoints details", "network", networkName, "endpointInfos", endpointInfos) klog.V(5).InfoS("Queried endpoints details", "network", networkName, "endpointInfos", endpointInfos)
return endpointInfos, nil return endpointInfos, nil
} }

View File

@ -85,16 +85,31 @@ type externalIPInfo struct {
hnsID string hnsID string
} }
func (info externalIPInfo) String() string {
return fmt.Sprintf("HnsID:%s, IP:%s", info.hnsID, info.ip)
}
type loadBalancerIngressInfo struct { type loadBalancerIngressInfo struct {
ip string ip string
hnsID string hnsID string
healthCheckHnsID string healthCheckHnsID string
} }
func (info loadBalancerIngressInfo) String() string {
if len(info.healthCheckHnsID) > 0 {
return fmt.Sprintf("HealthCheckHnsID:%s, IP:%s", info.healthCheckHnsID, info.ip)
}
return fmt.Sprintf("HnsID:%s, IP:%s", info.hnsID, info.ip)
}
type loadBalancerInfo struct { type loadBalancerInfo struct {
hnsID string hnsID string
} }
func (info loadBalancerInfo) String() string {
return fmt.Sprintf("HnsID:%s", info.hnsID)
}
type loadBalancerIdentifier struct { type loadBalancerIdentifier struct {
protocol uint16 protocol uint16
internalPort uint16 internalPort uint16
@ -103,6 +118,10 @@ type loadBalancerIdentifier struct {
endpointsHash [20]byte endpointsHash [20]byte
} }
func (info loadBalancerIdentifier) String() string {
return fmt.Sprintf("VIP:%s, Protocol:%d, InternalPort:%d, ExternalPort:%d", info.vip, info.protocol, info.internalPort, info.externalPort)
}
type loadBalancerFlags struct { type loadBalancerFlags struct {
isILB bool isILB bool
isDSR bool isDSR bool
@ -131,6 +150,20 @@ type serviceInfo struct {
winProxyOptimization bool winProxyOptimization bool
} }
func (info serviceInfo) String() string {
svcInfoStr := fmt.Sprintf("HnsID:%s, TargetPort:%d", info.hnsID, info.targetPort)
if info.nodePorthnsID != "" {
svcInfoStr = fmt.Sprintf("%s, NodePortHnsID:%s", svcInfoStr, info.nodePorthnsID)
}
if len(info.externalIPs) > 0 {
svcInfoStr = fmt.Sprintf("%s, ExternalIPs:%v", svcInfoStr, info.externalIPs)
}
if len(info.loadBalancerIngressIPs) > 0 {
svcInfoStr = fmt.Sprintf("%s, IngressIPs:%v", svcInfoStr, info.loadBalancerIngressIPs)
}
return svcInfoStr
}
type hnsNetworkInfo struct { type hnsNetworkInfo struct {
name string name string
id string id string
@ -291,8 +324,8 @@ type endpointInfo struct {
} }
// String is part of proxy.Endpoint interface. // String is part of proxy.Endpoint interface.
func (info *endpointInfo) String() string { func (info endpointInfo) String() string {
return net.JoinHostPort(info.ip, strconv.Itoa(int(info.port))) return fmt.Sprintf("HnsID:%s, Address:%s", info.hnsID, net.JoinHostPort(info.ip, strconv.Itoa(int(info.port))))
} }
// IsLocal is part of proxy.Endpoint interface. // IsLocal is part of proxy.Endpoint interface.
@ -1398,7 +1431,7 @@ func (proxier *Proxier) syncProxyRules() {
klog.V(3).InfoS("Endpoint resource found", "endpointInfo", ep) klog.V(3).InfoS("Endpoint resource found", "endpointInfo", ep)
} }
klog.V(3).InfoS("Associated endpoints for service", "endpointInfo", hnsEndpoints, "serviceName", svcName) klog.V(3).InfoS("Associated endpoints for service", "endpointInfo", fmt.Sprintf("%v", hnsEndpoints), "serviceName", svcName)
if len(svcInfo.hnsID) > 0 { if len(svcInfo.hnsID) > 0 {
// This should not happen // This should not happen
@ -1584,9 +1617,9 @@ func (proxier *Proxier) syncProxyRules() {
continue continue
} }
externalIP.hnsID = hnsLoadBalancer.hnsID externalIP.hnsID = hnsLoadBalancer.hnsID
klog.V(3).InfoS("Hns LoadBalancer resource created for externalIP resources", "externalIP", externalIP, "hnsID", hnsLoadBalancer.hnsID) klog.V(3).InfoS("Hns LoadBalancer resource created for externalIP resources", "externalIPInfo", externalIP, "hnsID", hnsLoadBalancer.hnsID)
} else { } else {
klog.V(3).InfoS("Skipped creating Hns LoadBalancer for externalIP resources", "externalIP", externalIP, "allEndpointsTerminating", allEndpointsTerminating) klog.V(3).InfoS("Skipped creating Hns LoadBalancer for externalIP resources", "externalIPInfo", externalIP, "allEndpointsTerminating", allEndpointsTerminating)
} }
} }
} }
@ -1634,9 +1667,9 @@ func (proxier *Proxier) syncProxyRules() {
continue continue
} }
lbIngressIP.hnsID = hnsLoadBalancer.hnsID lbIngressIP.hnsID = hnsLoadBalancer.hnsID
klog.V(3).InfoS("Hns LoadBalancer resource created for loadBalancer Ingress resources", "lbIngressIP", lbIngressIP) klog.V(3).InfoS("Hns LoadBalancer resource created for loadBalancer Ingress resources", "lbIngressIPInfo", lbIngressIP)
} else { } else {
klog.V(3).InfoS("Skipped creating Hns LoadBalancer for loadBalancer Ingress resources", "lbIngressIP", lbIngressIP) klog.V(3).InfoS("Skipped creating Hns LoadBalancer for loadBalancer Ingress resources", "lbIngressIPInfo", lbIngressIP)
} }
} }
@ -1687,7 +1720,7 @@ func (proxier *Proxier) syncProxyRules() {
klog.V(3).InfoS("Hns Health Check LoadBalancer resource created for loadBalancer Ingress resources", "ip", lbIngressIP) klog.V(3).InfoS("Hns Health Check LoadBalancer resource created for loadBalancer Ingress resources", "ip", lbIngressIP)
} }
} else { } else {
klog.V(3).InfoS("Skipped creating Hns Health Check LoadBalancer for loadBalancer Ingress resources", "ip", lbIngressIP, "allEndpointsTerminating", allEndpointsTerminating) klog.V(3).InfoS("Skipped creating Hns Health Check LoadBalancer for loadBalancer Ingress resources", "IngressIPInfo", lbIngressIP, "allEndpointsTerminating", allEndpointsTerminating)
} }
} }
svcInfo.policyApplied = true svcInfo.policyApplied = true