mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-04 15:05:20 +00:00
optimize proxier duplicate localaddrset
This commit is contained in:
@@ -1037,16 +1037,6 @@ func (proxier *Proxier) syncProxyRules() {
|
||||
klog.V(4).Infof("syncProxyRules took %v", time.Since(start))
|
||||
}()
|
||||
|
||||
localAddrs, err := utilproxy.GetLocalAddrs()
|
||||
if err != nil {
|
||||
klog.Errorf("Failed to get local addresses during proxy sync: %v, assuming external IPs are not local", err)
|
||||
} else if len(localAddrs) == 0 {
|
||||
klog.Warning("No local addresses found, assuming all external IPs are not local")
|
||||
}
|
||||
|
||||
localAddrSet := utilnet.IPSet{}
|
||||
localAddrSet.Insert(localAddrs...)
|
||||
|
||||
// We assume that if this was called, we really want to sync them,
|
||||
// even if nothing changed in the meantime. In other words, callers are
|
||||
// responsible for detecting no-op changes and not calling this function.
|
||||
@@ -1083,7 +1073,7 @@ func (proxier *Proxier) syncProxyRules() {
|
||||
proxier.createAndLinkKubeChain()
|
||||
|
||||
// make sure dummy interface exists in the system where ipvs Proxier will bind service address on it
|
||||
_, err = proxier.netlinkHandle.EnsureDummyDevice(DefaultDummyDevice)
|
||||
_, err := proxier.netlinkHandle.EnsureDummyDevice(DefaultDummyDevice)
|
||||
if err != nil {
|
||||
klog.Errorf("Failed to create dummy interface: %s, error: %v", DefaultDummyDevice, err)
|
||||
return
|
||||
@@ -1159,6 +1149,8 @@ func (proxier *Proxier) syncProxyRules() {
|
||||
// reset slice to filtered entries
|
||||
nodeIPs = nodeIPs[:idx]
|
||||
|
||||
localAddrSet := utilproxy.GetLocalAddrSet()
|
||||
|
||||
// Build IPVS rules for each service.
|
||||
for svcName, svc := range proxier.serviceMap {
|
||||
svcInfo, ok := svc.(*serviceInfo)
|
||||
|
||||
Reference in New Issue
Block a user