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).
This commit is contained in:
Dan Winship 2025-01-11 09:20:53 -05:00
parent 13f0449e4c
commit 36f5820ad1
6 changed files with 5 additions and 25 deletions

View File

@ -175,7 +175,6 @@ func (s *ProxyServer) createProxier(ctx context.Context, config *proxyconfigapi.
ctx, ctx,
ipt, ipt,
utilsysctl.New(), utilsysctl.New(),
exec.New(),
config.SyncPeriod.Duration, config.SyncPeriod.Duration,
config.MinSyncPeriod.Duration, config.MinSyncPeriod.Duration,
config.Linux.MasqueradeAll, config.Linux.MasqueradeAll,
@ -199,7 +198,6 @@ func (s *ProxyServer) createProxier(ctx context.Context, config *proxyconfigapi.
s.PrimaryIPFamily, s.PrimaryIPFamily,
iptInterface, iptInterface,
utilsysctl.New(), utilsysctl.New(),
exec.New(),
config.SyncPeriod.Duration, config.SyncPeriod.Duration,
config.MinSyncPeriod.Duration, config.MinSyncPeriod.Duration,
config.Linux.MasqueradeAll, config.Linux.MasqueradeAll,
@ -235,7 +233,6 @@ func (s *ProxyServer) createProxier(ctx context.Context, config *proxyconfigapi.
ipvsInterface, ipvsInterface,
ipsetInterface, ipsetInterface,
utilsysctl.New(), utilsysctl.New(),
execer,
config.SyncPeriod.Duration, config.SyncPeriod.Duration,
config.MinSyncPeriod.Duration, config.MinSyncPeriod.Duration,
config.IPVS.ExcludeCIDRs, config.IPVS.ExcludeCIDRs,
@ -263,7 +260,6 @@ func (s *ProxyServer) createProxier(ctx context.Context, config *proxyconfigapi.
ipvsInterface, ipvsInterface,
ipsetInterface, ipsetInterface,
utilsysctl.New(), utilsysctl.New(),
execer,
config.SyncPeriod.Duration, config.SyncPeriod.Duration,
config.MinSyncPeriod.Duration, config.MinSyncPeriod.Duration,
config.IPVS.ExcludeCIDRs, config.IPVS.ExcludeCIDRs,

View File

@ -54,7 +54,6 @@ import (
"k8s.io/kubernetes/pkg/proxy/util/nfacct" "k8s.io/kubernetes/pkg/proxy/util/nfacct"
"k8s.io/kubernetes/pkg/util/async" "k8s.io/kubernetes/pkg/util/async"
utiliptables "k8s.io/kubernetes/pkg/util/iptables" utiliptables "k8s.io/kubernetes/pkg/util/iptables"
utilexec "k8s.io/utils/exec"
) )
const ( const (
@ -101,7 +100,6 @@ func NewDualStackProxier(
ctx context.Context, ctx context.Context,
ipt [2]utiliptables.Interface, ipt [2]utiliptables.Interface,
sysctl utilsysctl.Interface, sysctl utilsysctl.Interface,
exec utilexec.Interface,
syncPeriod time.Duration, syncPeriod time.Duration,
minSyncPeriod time.Duration, minSyncPeriod time.Duration,
masqueradeAll bool, masqueradeAll bool,
@ -117,7 +115,7 @@ func NewDualStackProxier(
) (proxy.Provider, error) { ) (proxy.Provider, error) {
// Create an ipv4 instance of the single-stack proxier // Create an ipv4 instance of the single-stack proxier
ipv4Proxier, err := NewProxier(ctx, v1.IPv4Protocol, ipt[0], sysctl, 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], localDetectors[v1.IPv4Protocol], hostname, nodeIPs[v1.IPv4Protocol],
recorder, healthzServer, nodePortAddresses, initOnly) recorder, healthzServer, nodePortAddresses, initOnly)
if err != nil { if err != nil {
@ -125,7 +123,7 @@ func NewDualStackProxier(
} }
ipv6Proxier, err := NewProxier(ctx, v1.IPv6Protocol, ipt[1], sysctl, 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], localDetectors[v1.IPv6Protocol], hostname, nodeIPs[v1.IPv6Protocol],
recorder, healthzServer, nodePortAddresses, initOnly) recorder, healthzServer, nodePortAddresses, initOnly)
if err != nil { if err != nil {
@ -175,7 +173,6 @@ type Proxier struct {
localDetector proxyutil.LocalTrafficDetector localDetector proxyutil.LocalTrafficDetector
hostname string hostname string
nodeIP net.IP nodeIP net.IP
recorder events.EventRecorder
serviceHealthServer healthcheck.ServiceHealthServer serviceHealthServer healthcheck.ServiceHealthServer
healthzServer *healthcheck.ProxyHealthServer healthzServer *healthcheck.ProxyHealthServer
@ -230,7 +227,6 @@ func NewProxier(ctx context.Context,
ipFamily v1.IPFamily, ipFamily v1.IPFamily,
ipt utiliptables.Interface, ipt utiliptables.Interface,
sysctl utilsysctl.Interface, sysctl utilsysctl.Interface,
exec utilexec.Interface,
syncPeriod time.Duration, syncPeriod time.Duration,
minSyncPeriod time.Duration, minSyncPeriod time.Duration,
masqueradeAll bool, masqueradeAll bool,
@ -300,7 +296,6 @@ func NewProxier(ctx context.Context,
localDetector: localDetector, localDetector: localDetector,
hostname: hostname, hostname: hostname,
nodeIP: nodeIP, nodeIP: nodeIP,
recorder: recorder,
serviceHealthServer: serviceHealthServer, serviceHealthServer: serviceHealthServer,
healthzServer: healthzServer, healthzServer: healthzServer,
precomputedProbabilities: make([]string, 0, 1001), precomputedProbabilities: make([]string, 0, 1001),

View File

@ -53,7 +53,6 @@ import (
"k8s.io/kubernetes/pkg/util/async" "k8s.io/kubernetes/pkg/util/async"
utiliptables "k8s.io/kubernetes/pkg/util/iptables" utiliptables "k8s.io/kubernetes/pkg/util/iptables"
utilkernel "k8s.io/kubernetes/pkg/util/kernel" utilkernel "k8s.io/kubernetes/pkg/util/kernel"
utilexec "k8s.io/utils/exec"
netutils "k8s.io/utils/net" netutils "k8s.io/utils/net"
) )
@ -115,7 +114,6 @@ func NewDualStackProxier(
ipvs utilipvs.Interface, ipvs utilipvs.Interface,
ipset utilipset.Interface, ipset utilipset.Interface,
sysctl utilsysctl.Interface, sysctl utilsysctl.Interface,
exec utilexec.Interface,
syncPeriod time.Duration, syncPeriod time.Duration,
minSyncPeriod time.Duration, minSyncPeriod time.Duration,
excludeCIDRs []string, excludeCIDRs []string,
@ -136,7 +134,7 @@ func NewDualStackProxier(
) (proxy.Provider, error) { ) (proxy.Provider, error) {
// Create an ipv4 instance of the single-stack proxier // Create an ipv4 instance of the single-stack proxier
ipv4Proxier, err := NewProxier(ctx, v1.IPv4Protocol, ipt[0], ipvs, ipset, sysctl, 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, tcpTimeout, tcpFinTimeout, udpTimeout, masqueradeAll, masqueradeBit,
localDetectors[v1.IPv4Protocol], hostname, nodeIPs[v1.IPv4Protocol], recorder, localDetectors[v1.IPv4Protocol], hostname, nodeIPs[v1.IPv4Protocol], recorder,
healthzServer, scheduler, nodePortAddresses, initOnly) healthzServer, scheduler, nodePortAddresses, initOnly)
@ -145,7 +143,7 @@ func NewDualStackProxier(
} }
ipv6Proxier, err := NewProxier(ctx, v1.IPv6Protocol, ipt[1], ipvs, ipset, sysctl, 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, tcpTimeout, tcpFinTimeout, udpTimeout, masqueradeAll, masqueradeBit,
localDetectors[v1.IPv6Protocol], hostname, nodeIPs[v1.IPv6Protocol], recorder, localDetectors[v1.IPv6Protocol], hostname, nodeIPs[v1.IPv6Protocol], recorder,
healthzServer, scheduler, nodePortAddresses, initOnly) healthzServer, scheduler, nodePortAddresses, initOnly)
@ -197,8 +195,7 @@ type Proxier struct {
minSyncPeriod time.Duration minSyncPeriod time.Duration
// Values are CIDR's to exclude when cleaning up IPVS rules. // Values are CIDR's to exclude when cleaning up IPVS rules.
excludeCIDRs []*net.IPNet excludeCIDRs []*net.IPNet
// Set to true to set sysctls arp_ignore and arp_announce
strictARP bool
iptables utiliptables.Interface iptables utiliptables.Interface
ipvs utilipvs.Interface ipvs utilipvs.Interface
ipset utilipset.Interface ipset utilipset.Interface
@ -208,7 +205,6 @@ type Proxier struct {
localDetector proxyutil.LocalTrafficDetector localDetector proxyutil.LocalTrafficDetector
hostname string hostname string
nodeIP net.IP nodeIP net.IP
recorder events.EventRecorder
serviceHealthServer healthcheck.ServiceHealthServer serviceHealthServer healthcheck.ServiceHealthServer
healthzServer *healthcheck.ProxyHealthServer healthzServer *healthcheck.ProxyHealthServer
@ -270,7 +266,6 @@ func NewProxier(
ipvs utilipvs.Interface, ipvs utilipvs.Interface,
ipset utilipset.Interface, ipset utilipset.Interface,
sysctl utilsysctl.Interface, sysctl utilsysctl.Interface,
exec utilexec.Interface,
syncPeriod time.Duration, syncPeriod time.Duration,
minSyncPeriod time.Duration, minSyncPeriod time.Duration,
excludeCIDRs []string, excludeCIDRs []string,
@ -388,7 +383,6 @@ func NewProxier(
localDetector: localDetector, localDetector: localDetector,
hostname: hostname, hostname: hostname,
nodeIP: nodeIP, nodeIP: nodeIP,
recorder: recorder,
serviceHealthServer: serviceHealthServer, serviceHealthServer: serviceHealthServer,
healthzServer: healthzServer, healthzServer: healthzServer,
ipvs: ipvs, ipvs: ipvs,

View File

@ -149,7 +149,6 @@ func NewFakeProxier(ctx context.Context, ipt utiliptables.Interface, ipvs utilip
ipvs: ipvs, ipvs: ipvs,
ipset: ipset, ipset: ipset,
conntrack: conntrack.NewFake(), conntrack: conntrack.NewFake(),
strictARP: false,
localDetector: proxyutil.NewNoOpLocalDetector(), localDetector: proxyutil.NewNoOpLocalDetector(),
hostname: testHostname, hostname: testHostname,
serviceHealthServer: healthcheck.NewFakeServiceHealthServer(), serviceHealthServer: healthcheck.NewFakeServiceHealthServer(),

View File

@ -180,7 +180,6 @@ type Proxier struct {
localDetector proxyutil.LocalTrafficDetector localDetector proxyutil.LocalTrafficDetector
hostname string hostname string
nodeIP net.IP nodeIP net.IP
recorder events.EventRecorder
serviceHealthServer healthcheck.ServiceHealthServer serviceHealthServer healthcheck.ServiceHealthServer
healthzServer *healthcheck.ProxyHealthServer healthzServer *healthcheck.ProxyHealthServer
@ -265,7 +264,6 @@ func NewProxier(ctx context.Context,
localDetector: localDetector, localDetector: localDetector,
hostname: hostname, hostname: hostname,
nodeIP: nodeIP, nodeIP: nodeIP,
recorder: recorder,
serviceHealthServer: serviceHealthServer, serviceHealthServer: serviceHealthServer,
healthzServer: healthzServer, healthzServer: healthzServer,
nodePortAddresses: nodePortAddresses, nodePortAddresses: nodePortAddresses,

View File

@ -651,7 +651,6 @@ type Proxier struct {
// These are effectively const and do not need the mutex to be held. // These are effectively const and do not need the mutex to be held.
hostname string hostname string
nodeIP net.IP nodeIP net.IP
recorder events.EventRecorder
serviceHealthServer healthcheck.ServiceHealthServer serviceHealthServer healthcheck.ServiceHealthServer
healthzServer *healthcheck.ProxyHealthServer healthzServer *healthcheck.ProxyHealthServer
@ -813,7 +812,6 @@ func NewProxier(
endpointsMap: make(proxy.EndpointsMap), endpointsMap: make(proxy.EndpointsMap),
hostname: hostname, hostname: hostname,
nodeIP: nodeIP, nodeIP: nodeIP,
recorder: recorder,
serviceHealthServer: serviceHealthServer, serviceHealthServer: serviceHealthServer,
healthzServer: healthzServer, healthzServer: healthzServer,
hns: hns, hns: hns,