From 36f5820ad156c2353149b1cfd20f38d7be6a0943 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Sat, 11 Jan 2025 09:20:53 -0500 Subject: [PATCH] Remove some unused proxy args/fields Remove the utilexec.Interface args from the iptables/ipvs constructors (which have been unused since the conntrack cleanup code was ported to netlink). Remove the EventRecorder fields from the iptables/ipvs Proxiers, which have been unused since we removed the port-opener code in 2022. Remove the strictARP field from the ipvs Proxier, which has apparently always been unused (strictARP is only looked at at construct time). --- cmd/kube-proxy/app/server_linux.go | 4 ---- pkg/proxy/iptables/proxier.go | 9 ++------- pkg/proxy/ipvs/proxier.go | 12 +++--------- pkg/proxy/ipvs/proxier_test.go | 1 - pkg/proxy/nftables/proxier.go | 2 -- pkg/proxy/winkernel/proxier.go | 2 -- 6 files changed, 5 insertions(+), 25 deletions(-) diff --git a/cmd/kube-proxy/app/server_linux.go b/cmd/kube-proxy/app/server_linux.go index 56fb9d5e45e..d9a704860e9 100644 --- a/cmd/kube-proxy/app/server_linux.go +++ b/cmd/kube-proxy/app/server_linux.go @@ -175,7 +175,6 @@ func (s *ProxyServer) createProxier(ctx context.Context, config *proxyconfigapi. ctx, ipt, utilsysctl.New(), - exec.New(), config.SyncPeriod.Duration, config.MinSyncPeriod.Duration, config.Linux.MasqueradeAll, @@ -199,7 +198,6 @@ func (s *ProxyServer) createProxier(ctx context.Context, config *proxyconfigapi. s.PrimaryIPFamily, iptInterface, utilsysctl.New(), - exec.New(), config.SyncPeriod.Duration, config.MinSyncPeriod.Duration, config.Linux.MasqueradeAll, @@ -235,7 +233,6 @@ func (s *ProxyServer) createProxier(ctx context.Context, config *proxyconfigapi. ipvsInterface, ipsetInterface, utilsysctl.New(), - execer, config.SyncPeriod.Duration, config.MinSyncPeriod.Duration, config.IPVS.ExcludeCIDRs, @@ -263,7 +260,6 @@ func (s *ProxyServer) createProxier(ctx context.Context, config *proxyconfigapi. ipvsInterface, ipsetInterface, utilsysctl.New(), - execer, config.SyncPeriod.Duration, config.MinSyncPeriod.Duration, config.IPVS.ExcludeCIDRs, diff --git a/pkg/proxy/iptables/proxier.go b/pkg/proxy/iptables/proxier.go index 9c9e5f0c5cd..9e3ea0ade9e 100644 --- a/pkg/proxy/iptables/proxier.go +++ b/pkg/proxy/iptables/proxier.go @@ -54,7 +54,6 @@ import ( "k8s.io/kubernetes/pkg/proxy/util/nfacct" "k8s.io/kubernetes/pkg/util/async" utiliptables "k8s.io/kubernetes/pkg/util/iptables" - utilexec "k8s.io/utils/exec" ) const ( @@ -101,7 +100,6 @@ func NewDualStackProxier( ctx context.Context, ipt [2]utiliptables.Interface, sysctl utilsysctl.Interface, - exec utilexec.Interface, syncPeriod time.Duration, minSyncPeriod time.Duration, masqueradeAll bool, @@ -117,7 +115,7 @@ func NewDualStackProxier( ) (proxy.Provider, error) { // Create an ipv4 instance of the single-stack proxier ipv4Proxier, err := NewProxier(ctx, v1.IPv4Protocol, ipt[0], sysctl, - exec, syncPeriod, minSyncPeriod, masqueradeAll, localhostNodePorts, masqueradeBit, + syncPeriod, minSyncPeriod, masqueradeAll, localhostNodePorts, masqueradeBit, localDetectors[v1.IPv4Protocol], hostname, nodeIPs[v1.IPv4Protocol], recorder, healthzServer, nodePortAddresses, initOnly) if err != nil { @@ -125,7 +123,7 @@ func NewDualStackProxier( } ipv6Proxier, err := NewProxier(ctx, v1.IPv6Protocol, ipt[1], sysctl, - exec, syncPeriod, minSyncPeriod, masqueradeAll, false, masqueradeBit, + syncPeriod, minSyncPeriod, masqueradeAll, false, masqueradeBit, localDetectors[v1.IPv6Protocol], hostname, nodeIPs[v1.IPv6Protocol], recorder, healthzServer, nodePortAddresses, initOnly) if err != nil { @@ -175,7 +173,6 @@ type Proxier struct { localDetector proxyutil.LocalTrafficDetector hostname string nodeIP net.IP - recorder events.EventRecorder serviceHealthServer healthcheck.ServiceHealthServer healthzServer *healthcheck.ProxyHealthServer @@ -230,7 +227,6 @@ func NewProxier(ctx context.Context, ipFamily v1.IPFamily, ipt utiliptables.Interface, sysctl utilsysctl.Interface, - exec utilexec.Interface, syncPeriod time.Duration, minSyncPeriod time.Duration, masqueradeAll bool, @@ -300,7 +296,6 @@ func NewProxier(ctx context.Context, localDetector: localDetector, hostname: hostname, nodeIP: nodeIP, - recorder: recorder, serviceHealthServer: serviceHealthServer, healthzServer: healthzServer, precomputedProbabilities: make([]string, 0, 1001), diff --git a/pkg/proxy/ipvs/proxier.go b/pkg/proxy/ipvs/proxier.go index 8f96e692b70..c035b150491 100644 --- a/pkg/proxy/ipvs/proxier.go +++ b/pkg/proxy/ipvs/proxier.go @@ -53,7 +53,6 @@ import ( "k8s.io/kubernetes/pkg/util/async" utiliptables "k8s.io/kubernetes/pkg/util/iptables" utilkernel "k8s.io/kubernetes/pkg/util/kernel" - utilexec "k8s.io/utils/exec" netutils "k8s.io/utils/net" ) @@ -115,7 +114,6 @@ func NewDualStackProxier( ipvs utilipvs.Interface, ipset utilipset.Interface, sysctl utilsysctl.Interface, - exec utilexec.Interface, syncPeriod time.Duration, minSyncPeriod time.Duration, excludeCIDRs []string, @@ -136,7 +134,7 @@ func NewDualStackProxier( ) (proxy.Provider, error) { // Create an ipv4 instance of the single-stack proxier ipv4Proxier, err := NewProxier(ctx, v1.IPv4Protocol, ipt[0], ipvs, ipset, sysctl, - exec, syncPeriod, minSyncPeriod, filterCIDRs(false, excludeCIDRs), strictARP, + syncPeriod, minSyncPeriod, filterCIDRs(false, excludeCIDRs), strictARP, tcpTimeout, tcpFinTimeout, udpTimeout, masqueradeAll, masqueradeBit, localDetectors[v1.IPv4Protocol], hostname, nodeIPs[v1.IPv4Protocol], recorder, healthzServer, scheduler, nodePortAddresses, initOnly) @@ -145,7 +143,7 @@ func NewDualStackProxier( } ipv6Proxier, err := NewProxier(ctx, v1.IPv6Protocol, ipt[1], ipvs, ipset, sysctl, - exec, syncPeriod, minSyncPeriod, filterCIDRs(true, excludeCIDRs), strictARP, + syncPeriod, minSyncPeriod, filterCIDRs(true, excludeCIDRs), strictARP, tcpTimeout, tcpFinTimeout, udpTimeout, masqueradeAll, masqueradeBit, localDetectors[v1.IPv6Protocol], hostname, nodeIPs[v1.IPv6Protocol], recorder, healthzServer, scheduler, nodePortAddresses, initOnly) @@ -197,8 +195,7 @@ type Proxier struct { minSyncPeriod time.Duration // Values are CIDR's to exclude when cleaning up IPVS rules. excludeCIDRs []*net.IPNet - // Set to true to set sysctls arp_ignore and arp_announce - strictARP bool + iptables utiliptables.Interface ipvs utilipvs.Interface ipset utilipset.Interface @@ -208,7 +205,6 @@ type Proxier struct { localDetector proxyutil.LocalTrafficDetector hostname string nodeIP net.IP - recorder events.EventRecorder serviceHealthServer healthcheck.ServiceHealthServer healthzServer *healthcheck.ProxyHealthServer @@ -270,7 +266,6 @@ func NewProxier( ipvs utilipvs.Interface, ipset utilipset.Interface, sysctl utilsysctl.Interface, - exec utilexec.Interface, syncPeriod time.Duration, minSyncPeriod time.Duration, excludeCIDRs []string, @@ -388,7 +383,6 @@ func NewProxier( localDetector: localDetector, hostname: hostname, nodeIP: nodeIP, - recorder: recorder, serviceHealthServer: serviceHealthServer, healthzServer: healthzServer, ipvs: ipvs, diff --git a/pkg/proxy/ipvs/proxier_test.go b/pkg/proxy/ipvs/proxier_test.go index 86aacbd3634..c835ade5c46 100644 --- a/pkg/proxy/ipvs/proxier_test.go +++ b/pkg/proxy/ipvs/proxier_test.go @@ -149,7 +149,6 @@ func NewFakeProxier(ctx context.Context, ipt utiliptables.Interface, ipvs utilip ipvs: ipvs, ipset: ipset, conntrack: conntrack.NewFake(), - strictARP: false, localDetector: proxyutil.NewNoOpLocalDetector(), hostname: testHostname, serviceHealthServer: healthcheck.NewFakeServiceHealthServer(), diff --git a/pkg/proxy/nftables/proxier.go b/pkg/proxy/nftables/proxier.go index 36f4b2ee764..d7d8976664e 100644 --- a/pkg/proxy/nftables/proxier.go +++ b/pkg/proxy/nftables/proxier.go @@ -180,7 +180,6 @@ type Proxier struct { localDetector proxyutil.LocalTrafficDetector hostname string nodeIP net.IP - recorder events.EventRecorder serviceHealthServer healthcheck.ServiceHealthServer healthzServer *healthcheck.ProxyHealthServer @@ -265,7 +264,6 @@ func NewProxier(ctx context.Context, localDetector: localDetector, hostname: hostname, nodeIP: nodeIP, - recorder: recorder, serviceHealthServer: serviceHealthServer, healthzServer: healthzServer, nodePortAddresses: nodePortAddresses, diff --git a/pkg/proxy/winkernel/proxier.go b/pkg/proxy/winkernel/proxier.go index 3e038683109..a4e57dd36e2 100644 --- a/pkg/proxy/winkernel/proxier.go +++ b/pkg/proxy/winkernel/proxier.go @@ -651,7 +651,6 @@ type Proxier struct { // These are effectively const and do not need the mutex to be held. hostname string nodeIP net.IP - recorder events.EventRecorder serviceHealthServer healthcheck.ServiceHealthServer healthzServer *healthcheck.ProxyHealthServer @@ -813,7 +812,6 @@ func NewProxier( endpointsMap: make(proxy.EndpointsMap), hostname: hostname, nodeIP: nodeIP, - recorder: recorder, serviceHealthServer: serviceHealthServer, healthzServer: healthzServer, hns: hns,