Skip to content

Commit 9f8d532

Browse files
authored
Merge pull request kubernetes#130266 from princepereira/ppereira-winproxy-logformat
Introduced additional log formatting to windows kubeproxy.
2 parents c75960c + 3d00753 commit 9f8d532

File tree

2 files changed

+42
-9
lines changed

2 files changed

+42
-9
lines changed

pkg/proxy/winkernel/hns.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ func (hns hns) getAllEndpointsByNetwork(networkName string) (map[string]*(endpoi
168168
}
169169
endpointInfos[ep.IpConfigurations[1].IpAddress] = endpointDualstack
170170
}
171-
klog.V(3).InfoS("Queried endpoints from network", "network", networkName)
171+
klog.V(3).InfoS("Queried endpoints from network", "network", networkName, "count", len(endpointInfos))
172172
klog.V(5).InfoS("Queried endpoints details", "network", networkName, "endpointInfos", endpointInfos)
173173
return endpointInfos, nil
174174
}

pkg/proxy/winkernel/proxier.go

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,31 @@ type externalIPInfo struct {
8585
hnsID string
8686
}
8787

88+
func (info externalIPInfo) String() string {
89+
return fmt.Sprintf("HnsID:%s, IP:%s", info.hnsID, info.ip)
90+
}
91+
8892
type loadBalancerIngressInfo struct {
8993
ip string
9094
hnsID string
9195
healthCheckHnsID string
9296
}
9397

98+
func (info loadBalancerIngressInfo) String() string {
99+
if len(info.healthCheckHnsID) > 0 {
100+
return fmt.Sprintf("HealthCheckHnsID:%s, IP:%s", info.healthCheckHnsID, info.ip)
101+
}
102+
return fmt.Sprintf("HnsID:%s, IP:%s", info.hnsID, info.ip)
103+
}
104+
94105
type loadBalancerInfo struct {
95106
hnsID string
96107
}
97108

109+
func (info loadBalancerInfo) String() string {
110+
return fmt.Sprintf("HnsID:%s", info.hnsID)
111+
}
112+
98113
type loadBalancerIdentifier struct {
99114
protocol uint16
100115
internalPort uint16
@@ -103,6 +118,10 @@ type loadBalancerIdentifier struct {
103118
endpointsHash [20]byte
104119
}
105120

121+
func (info loadBalancerIdentifier) String() string {
122+
return fmt.Sprintf("VIP:%s, Protocol:%d, InternalPort:%d, ExternalPort:%d", info.vip, info.protocol, info.internalPort, info.externalPort)
123+
}
124+
106125
type loadBalancerFlags struct {
107126
isILB bool
108127
isDSR bool
@@ -131,6 +150,20 @@ type serviceInfo struct {
131150
winProxyOptimization bool
132151
}
133152

153+
func (info serviceInfo) String() string {
154+
svcInfoStr := fmt.Sprintf("HnsID:%s, TargetPort:%d", info.hnsID, info.targetPort)
155+
if info.nodePorthnsID != "" {
156+
svcInfoStr = fmt.Sprintf("%s, NodePortHnsID:%s", svcInfoStr, info.nodePorthnsID)
157+
}
158+
if len(info.externalIPs) > 0 {
159+
svcInfoStr = fmt.Sprintf("%s, ExternalIPs:%v", svcInfoStr, info.externalIPs)
160+
}
161+
if len(info.loadBalancerIngressIPs) > 0 {
162+
svcInfoStr = fmt.Sprintf("%s, IngressIPs:%v", svcInfoStr, info.loadBalancerIngressIPs)
163+
}
164+
return svcInfoStr
165+
}
166+
134167
type hnsNetworkInfo struct {
135168
name string
136169
id string
@@ -291,8 +324,8 @@ type endpointInfo struct {
291324
}
292325

293326
// String is part of proxy.Endpoint interface.
294-
func (info *endpointInfo) String() string {
295-
return net.JoinHostPort(info.ip, strconv.Itoa(int(info.port)))
327+
func (info endpointInfo) String() string {
328+
return fmt.Sprintf("HnsID:%s, Address:%s", info.hnsID, net.JoinHostPort(info.ip, strconv.Itoa(int(info.port))))
296329
}
297330

298331
// IsLocal is part of proxy.Endpoint interface.
@@ -1396,7 +1429,7 @@ func (proxier *Proxier) syncProxyRules() {
13961429
klog.V(3).InfoS("Endpoint resource found", "endpointInfo", ep)
13971430
}
13981431

1399-
klog.V(3).InfoS("Associated endpoints for service", "endpointInfo", hnsEndpoints, "serviceName", svcName)
1432+
klog.V(3).InfoS("Associated endpoints for service", "endpointInfo", fmt.Sprintf("%v", hnsEndpoints), "serviceName", svcName)
14001433

14011434
if len(svcInfo.hnsID) > 0 {
14021435
// This should not happen
@@ -1582,9 +1615,9 @@ func (proxier *Proxier) syncProxyRules() {
15821615
continue
15831616
}
15841617
externalIP.hnsID = hnsLoadBalancer.hnsID
1585-
klog.V(3).InfoS("Hns LoadBalancer resource created for externalIP resources", "externalIP", externalIP, "hnsID", hnsLoadBalancer.hnsID)
1618+
klog.V(3).InfoS("Hns LoadBalancer resource created for externalIP resources", "externalIPInfo", externalIP, "hnsID", hnsLoadBalancer.hnsID)
15861619
} else {
1587-
klog.V(3).InfoS("Skipped creating Hns LoadBalancer for externalIP resources", "externalIP", externalIP, "allEndpointsTerminating", allEndpointsTerminating)
1620+
klog.V(3).InfoS("Skipped creating Hns LoadBalancer for externalIP resources", "externalIPInfo", externalIP, "allEndpointsTerminating", allEndpointsTerminating)
15881621
}
15891622
}
15901623
}
@@ -1632,9 +1665,9 @@ func (proxier *Proxier) syncProxyRules() {
16321665
continue
16331666
}
16341667
lbIngressIP.hnsID = hnsLoadBalancer.hnsID
1635-
klog.V(3).InfoS("Hns LoadBalancer resource created for loadBalancer Ingress resources", "lbIngressIP", lbIngressIP)
1668+
klog.V(3).InfoS("Hns LoadBalancer resource created for loadBalancer Ingress resources", "lbIngressIPInfo", lbIngressIP)
16361669
} else {
1637-
klog.V(3).InfoS("Skipped creating Hns LoadBalancer for loadBalancer Ingress resources", "lbIngressIP", lbIngressIP)
1670+
klog.V(3).InfoS("Skipped creating Hns LoadBalancer for loadBalancer Ingress resources", "lbIngressIPInfo", lbIngressIP)
16381671
}
16391672
}
16401673

@@ -1685,7 +1718,7 @@ func (proxier *Proxier) syncProxyRules() {
16851718
klog.V(3).InfoS("Hns Health Check LoadBalancer resource created for loadBalancer Ingress resources", "ip", lbIngressIP)
16861719
}
16871720
} else {
1688-
klog.V(3).InfoS("Skipped creating Hns Health Check LoadBalancer for loadBalancer Ingress resources", "ip", lbIngressIP, "allEndpointsTerminating", allEndpointsTerminating)
1721+
klog.V(3).InfoS("Skipped creating Hns Health Check LoadBalancer for loadBalancer Ingress resources", "IngressIPInfo", lbIngressIP, "allEndpointsTerminating", allEndpointsTerminating)
16891722
}
16901723
}
16911724
svcInfo.policyApplied = true

0 commit comments

Comments
 (0)