[kube-proxy/ipvs] Gofmt
This commit is contained in:
parent
0f9d30dd27
commit
ec598d1a16
@ -1196,7 +1196,7 @@ func (proxier *Proxier) syncProxyRules() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Errorf("Failed to get bind address, err: %v", err)
|
klog.Errorf("Failed to get bind address, err: %v", err)
|
||||||
}
|
}
|
||||||
legacyBindAddrs := proxier.getLegacyBindAddr(activeBindAddrs,currentBindAddrs)
|
legacyBindAddrs := proxier.getLegacyBindAddr(activeBindAddrs, currentBindAddrs)
|
||||||
|
|
||||||
// Clean up legacy IPVS services and unbind addresses
|
// Clean up legacy IPVS services and unbind addresses
|
||||||
appliedSvcs, err := proxier.ipvs.GetVirtualServers()
|
appliedSvcs, err := proxier.ipvs.GetVirtualServers()
|
||||||
@ -1646,14 +1646,14 @@ func (proxier *Proxier) cleanLegacyService(activeServices map[string]bool, curre
|
|||||||
if err := proxier.ipvs.DeleteVirtualServer(svc); err != nil {
|
if err := proxier.ipvs.DeleteVirtualServer(svc); err != nil {
|
||||||
klog.Errorf("Failed to delete service %s, error: %v", svc.String(), err)
|
klog.Errorf("Failed to delete service %s, error: %v", svc.String(), err)
|
||||||
}
|
}
|
||||||
addr:=svc.Address.String()
|
addr := svc.Address.String()
|
||||||
if _, ok := legacyBindAddrs[addr]; ok {
|
if _, ok := legacyBindAddrs[addr]; ok {
|
||||||
klog.V(4).Infof("Unbinding address %s", addr)
|
klog.V(4).Infof("Unbinding address %s", addr)
|
||||||
if err := proxier.netlinkHandle.UnbindAddress(addr, DefaultDummyDevice); err != nil {
|
if err := proxier.netlinkHandle.UnbindAddress(addr, DefaultDummyDevice); err != nil {
|
||||||
klog.Errorf("Failed to unbind service addr %s from dummy interface %s: %v", addr, DefaultDummyDevice, err)
|
klog.Errorf("Failed to unbind service addr %s from dummy interface %s: %v", addr, DefaultDummyDevice, err)
|
||||||
} else {
|
} else {
|
||||||
// In case we delete a multi-port service, avoid trying to unbind multiple times
|
// In case we delete a multi-port service, avoid trying to unbind multiple times
|
||||||
delete(legacyBindAddrs,addr)
|
delete(legacyBindAddrs, addr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1662,10 +1662,10 @@ func (proxier *Proxier) cleanLegacyService(activeServices map[string]bool, curre
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (proxier *Proxier) getLegacyBindAddr(activeBindAddrs map[string]bool, currentBindAddrs []string) map[string]bool {
|
func (proxier *Proxier) getLegacyBindAddr(activeBindAddrs map[string]bool, currentBindAddrs []string) map[string]bool {
|
||||||
legacyAddrs := make(map[string]bool)
|
legacyAddrs := make(map[string]bool)
|
||||||
for _, addr := range currentBindAddrs {
|
for _, addr := range currentBindAddrs {
|
||||||
if _, ok := activeBindAddrs[addr]; !ok {
|
if _, ok := activeBindAddrs[addr]; !ok {
|
||||||
legacyAddrs[addr]=true
|
legacyAddrs[addr] = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return legacyAddrs
|
return legacyAddrs
|
||||||
|
@ -2871,10 +2871,10 @@ func TestCleanLegacyService(t *testing.T) {
|
|||||||
activeBindAddrs := map[string]bool{"1.1.1.1": true, "2.2.2.2": true, "3.3.3.3": true, "4.4.4.4": true}
|
activeBindAddrs := map[string]bool{"1.1.1.1": true, "2.2.2.2": true, "3.3.3.3": true, "4.4.4.4": true}
|
||||||
currentBindAddrs := []string{"1.1.1.1", "2.2.2.2", "3.3.3.3", "4.4.4.4", "5.5.5.5", "6.6.6.6"}
|
currentBindAddrs := []string{"1.1.1.1", "2.2.2.2", "3.3.3.3", "4.4.4.4", "5.5.5.5", "6.6.6.6"}
|
||||||
for i := range currentBindAddrs {
|
for i := range currentBindAddrs {
|
||||||
fp.netlinkHandle.EnsureAddressBind(currentBindAddrs[i], DefaultDummyDevice)
|
fp.netlinkHandle.EnsureAddressBind(currentBindAddrs[i], DefaultDummyDevice)
|
||||||
}
|
}
|
||||||
|
|
||||||
fp.cleanLegacyService(activeServices, currentServices, map[string]bool{"5.5.5.5":true,"6.6.6.6":true})
|
fp.cleanLegacyService(activeServices, currentServices, map[string]bool{"5.5.5.5": true, "6.6.6.6": true})
|
||||||
// ipvs4 and ipvs5 should have been cleaned.
|
// ipvs4 and ipvs5 should have been cleaned.
|
||||||
remainingVirtualServers, _ := fp.ipvs.GetVirtualServers()
|
remainingVirtualServers, _ := fp.ipvs.GetVirtualServers()
|
||||||
if len(remainingVirtualServers) != 4 {
|
if len(remainingVirtualServers) != 4 {
|
||||||
|
Loading…
Reference in New Issue
Block a user