Skip to content

Commit ffe74b2

Browse files
authored
Merge pull request kubernetes#97336 from maaoBit/remove_cleanup-ipvs
remove --cleanup-ipvs flag of kube-proxy
2 parents 36bde43 + d001b9b commit ffe74b2

3 files changed

Lines changed: 5 additions & 15 deletions

File tree

cmd/kube-proxy/app/server.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@ type Options struct {
108108
WriteConfigTo string
109109
// CleanupAndExit, when true, makes the proxy server clean up iptables and ipvs rules, then exit.
110110
CleanupAndExit bool
111-
// CleanupIPVS, when true, makes the proxy server clean up ipvs rules before running.
112-
CleanupIPVS bool
113111
// WindowsService should be set to true if kube-proxy is running as a service on Windows.
114112
// Its corresponding flag only gets registered in Windows builds
115113
WindowsService bool
@@ -162,8 +160,6 @@ func (o *Options) AddFlags(fs *pflag.FlagSet) {
162160
"A string slice of values which specify the addresses to use for NodePorts. Values may be valid IP blocks (e.g. 1.2.3.0/24, 1.2.3.4/32). The default empty string slice ([]) means to use all local addresses.")
163161

164162
fs.BoolVar(&o.CleanupAndExit, "cleanup", o.CleanupAndExit, "If true cleanup iptables and ipvs rules and exit.")
165-
fs.BoolVar(&o.CleanupIPVS, "cleanup-ipvs", o.CleanupIPVS, "If true and --cleanup is specified, kube-proxy will also flush IPVS rules, in addition to normal cleanup.")
166-
fs.MarkDeprecated("cleanup-ipvs", "In a future release, running --cleanup will always flush IPVS rules")
167163

168164
fs.Var(utilflag.IPVar{Val: &o.config.BindAddress}, "bind-address", "The IP address for the proxy server to serve on (set to '0.0.0.0' for all IPv4 interfaces and '::' for all IPv6 interfaces)")
169165
fs.Var(utilflag.IPPortVar{Val: &o.config.HealthzBindAddress}, "healthz-bind-address", "The IP address with port for the health check server to serve on (set to '0.0.0.0:10256' for all IPv4 interfaces and '[::]:10256' for all IPv6 interfaces). Set empty to disable.")
@@ -215,7 +211,6 @@ func NewOptions() *Options {
215211
config: new(kubeproxyconfig.KubeProxyConfiguration),
216212
healthzPort: ports.ProxyHealthzPort,
217213
metricsPort: ports.ProxyStatusPort,
218-
CleanupIPVS: true,
219214
errCh: make(chan error),
220215
}
221216
}
@@ -535,7 +530,6 @@ type ProxyServer struct {
535530
Conntracker Conntracker // if nil, ignored
536531
ProxyMode string
537532
NodeRef *v1.ObjectReference
538-
CleanupIPVS bool
539533
MetricsBindAddress string
540534
BindAddressHardFail bool
541535
EnableProfiling bool
@@ -813,7 +807,7 @@ func (s *ProxyServer) CleanupAndExit() error {
813807
for _, ipt := range ipts {
814808
encounteredError = userspace.CleanupLeftovers(ipt) || encounteredError
815809
encounteredError = iptables.CleanupLeftovers(ipt) || encounteredError
816-
encounteredError = ipvs.CleanupLeftovers(s.IpvsInterface, ipt, s.IpsetInterface, s.CleanupIPVS) || encounteredError
810+
encounteredError = ipvs.CleanupLeftovers(s.IpvsInterface, ipt, s.IpsetInterface) || encounteredError
817811
}
818812
if encounteredError {
819813
return errors.New("encountered an error while tearing down rules")

pkg/proxy/ipvs/proxier.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -803,13 +803,9 @@ func cleanupIptablesLeftovers(ipt utiliptables.Interface) (encounteredError bool
803803
}
804804

805805
// CleanupLeftovers clean up all ipvs and iptables rules created by ipvs Proxier.
806-
func CleanupLeftovers(ipvs utilipvs.Interface, ipt utiliptables.Interface, ipset utilipset.Interface, cleanupIPVS bool) (encounteredError bool) {
807-
if cleanupIPVS {
808-
// Return immediately when ipvs interface is nil - Probably initialization failed in somewhere.
809-
if ipvs == nil {
810-
return true
811-
}
812-
encounteredError = false
806+
func CleanupLeftovers(ipvs utilipvs.Interface, ipt utiliptables.Interface, ipset utilipset.Interface) (encounteredError bool) {
807+
// Clear all ipvs rules
808+
if ipvs != nil {
813809
err := ipvs.Flush()
814810
if err != nil {
815811
klog.Errorf("Error flushing IPVS rules: %v", err)

pkg/proxy/ipvs/proxier_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ func TestCleanupLeftovers(t *testing.T) {
266266
fp.syncProxyRules()
267267

268268
// test cleanup left over
269-
if CleanupLeftovers(ipvs, ipt, ipset, true) {
269+
if CleanupLeftovers(ipvs, ipt, ipset) {
270270
t.Errorf("Cleanup leftovers failed")
271271
}
272272
}

0 commit comments

Comments
 (0)