mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Not step into ipvs.CleanupLeftovers() if canUseIPVS's false
This commit is contained in:
parent
7a9a30a4f7
commit
405d5f802c
@ -92,7 +92,8 @@ func newProxyServer(
|
|||||||
iptInterface = utiliptables.New(execer, dbus, protocol)
|
iptInterface = utiliptables.New(execer, dbus, protocol)
|
||||||
kernelHandler = ipvs.NewLinuxKernelHandler()
|
kernelHandler = ipvs.NewLinuxKernelHandler()
|
||||||
ipsetInterface = utilipset.New(execer)
|
ipsetInterface = utilipset.New(execer)
|
||||||
if canUse, _ := ipvs.CanUseIPVSProxier(kernelHandler, ipsetInterface); canUse {
|
canUseIPVS, _ := ipvs.CanUseIPVSProxier(kernelHandler, ipsetInterface)
|
||||||
|
if canUseIPVS {
|
||||||
ipvsInterface = utilipvs.New(execer)
|
ipvsInterface = utilipvs.New(execer)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,7 +179,9 @@ func newProxyServer(
|
|||||||
// Besides, ipvs proxier will create some ipvs rules as well. Because there is no way to tell if a given
|
// Besides, ipvs proxier will create some ipvs rules as well. Because there is no way to tell if a given
|
||||||
// ipvs rule is created by IPVS proxier or not. Users should explicitly specify `--clean-ipvs=true` to flush
|
// ipvs rule is created by IPVS proxier or not. Users should explicitly specify `--clean-ipvs=true` to flush
|
||||||
// all ipvs rules when kube-proxy start up. Users do this operation should be with caution.
|
// all ipvs rules when kube-proxy start up. Users do this operation should be with caution.
|
||||||
|
if canUseIPVS {
|
||||||
ipvs.CleanupLeftovers(ipvsInterface, iptInterface, ipsetInterface, cleanupIPVS)
|
ipvs.CleanupLeftovers(ipvsInterface, iptInterface, ipsetInterface, cleanupIPVS)
|
||||||
|
}
|
||||||
} else if proxyMode == proxyModeIPVS {
|
} else if proxyMode == proxyModeIPVS {
|
||||||
glog.V(0).Info("Using ipvs Proxier.")
|
glog.V(0).Info("Using ipvs Proxier.")
|
||||||
proxierIPVS, err := ipvs.NewProxier(
|
proxierIPVS, err := ipvs.NewProxier(
|
||||||
@ -245,8 +248,10 @@ func newProxyServer(
|
|||||||
// Besides, ipvs proxier will create some ipvs rules as well. Because there is no way to tell if a given
|
// Besides, ipvs proxier will create some ipvs rules as well. Because there is no way to tell if a given
|
||||||
// ipvs rule is created by IPVS proxier or not. Users should explicitly specify `--clean-ipvs=true` to flush
|
// ipvs rule is created by IPVS proxier or not. Users should explicitly specify `--clean-ipvs=true` to flush
|
||||||
// all ipvs rules when kube-proxy start up. Users do this operation should be with caution.
|
// all ipvs rules when kube-proxy start up. Users do this operation should be with caution.
|
||||||
|
if canUseIPVS {
|
||||||
ipvs.CleanupLeftovers(ipvsInterface, iptInterface, ipsetInterface, cleanupIPVS)
|
ipvs.CleanupLeftovers(ipvsInterface, iptInterface, ipsetInterface, cleanupIPVS)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
iptInterface.AddReloadFunc(proxier.Sync)
|
iptInterface.AddReloadFunc(proxier.Sync)
|
||||||
|
|
||||||
|
@ -548,9 +548,6 @@ func cleanupIptablesLeftovers(ipt utiliptables.Interface) (encounteredError bool
|
|||||||
|
|
||||||
// CleanupLeftovers clean up all ipvs and iptables rules created by ipvs Proxier.
|
// CleanupLeftovers clean up all ipvs and iptables rules created by ipvs Proxier.
|
||||||
func CleanupLeftovers(ipvs utilipvs.Interface, ipt utiliptables.Interface, ipset utilipset.Interface, cleanupIPVS bool) (encounteredError bool) {
|
func CleanupLeftovers(ipvs utilipvs.Interface, ipt utiliptables.Interface, ipset utilipset.Interface, cleanupIPVS bool) (encounteredError bool) {
|
||||||
if canUse, _ := CanUseIPVSProxier(NewLinuxKernelHandler(), ipset); !canUse {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if cleanupIPVS {
|
if cleanupIPVS {
|
||||||
// Return immediately when ipvs interface is nil - Probably initialization failed in somewhere.
|
// Return immediately when ipvs interface is nil - Probably initialization failed in somewhere.
|
||||||
if ipvs == nil {
|
if ipvs == nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user