mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
proxy/ipvs: Compute all node ips only once when a zero cidr is used
Computing all node ips twice would always happen when no node port addresses were explicitly set. The GetNodeAddresses call would return two zero cidrs (ipv4 and ipv6) and we would then retrieve all node IPs twice because the loop wouldn't break after the first time. Also, it is possible for the user to set explicit node port addresses including both a zero and a non-zero cidr, but this wouldn't make sense for nodeIPs since the zero cidr would already cause nodeIPs to include all IPs on the node.
This commit is contained in:
parent
5c16940508
commit
c25763e159
@ -834,15 +834,14 @@ func (proxier *Proxier) syncProxyRules() {
|
||||
if err == nil && nodeAddrSet.Len() > 0 {
|
||||
nodeAddresses = nodeAddrSet.List()
|
||||
for _, address := range nodeAddresses {
|
||||
if !utilproxy.IsZeroCIDR(address) {
|
||||
nodeIPs = append(nodeIPs, net.ParseIP(address))
|
||||
continue
|
||||
}
|
||||
// zero cidr
|
||||
if utilproxy.IsZeroCIDR(address) {
|
||||
nodeIPs, err = proxier.ipGetter.NodeIPs()
|
||||
if err != nil {
|
||||
klog.Errorf("Failed to list all node IPs from host, err: %v", err)
|
||||
}
|
||||
break
|
||||
}
|
||||
nodeIPs = append(nodeIPs, net.ParseIP(address))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user