mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-06 07:57:35 +00:00
iptables: remove port opener
This commit is contained in:
@@ -361,26 +361,6 @@ func TestDeleteEndpointConnectionsIPv6(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// fakeCloseable implements utilproxy.Closeable
|
||||
type fakeCloseable struct{}
|
||||
|
||||
// Close fakes out the close() used by syncProxyRules to release a local port.
|
||||
func (f *fakeCloseable) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// fakePortOpener implements portOpener.
|
||||
type fakePortOpener struct {
|
||||
openPorts []*netutils.LocalPort
|
||||
}
|
||||
|
||||
// OpenLocalPort fakes out the listen() and bind() used by syncProxyRules
|
||||
// to lock a local port.
|
||||
func (f *fakePortOpener) OpenLocalPort(lp *netutils.LocalPort) (netutils.Closeable, error) {
|
||||
f.openPorts = append(f.openPorts, lp)
|
||||
return &fakeCloseable{}, nil
|
||||
}
|
||||
|
||||
// Conventions for tests using NewFakeProxier:
|
||||
//
|
||||
// Pod IPs: 10.0.0.0/8
|
||||
@@ -427,8 +407,6 @@ func NewFakeProxier(ipt utiliptables.Interface) *Proxier {
|
||||
masqueradeMark: "0x4000",
|
||||
localDetector: detectLocal,
|
||||
hostname: testHostname,
|
||||
portsMap: make(map[netutils.LocalPort]netutils.Closeable),
|
||||
portMapper: &fakePortOpener{[]*netutils.LocalPort{}},
|
||||
serviceHealthServer: healthcheck.NewFakeServiceHealthServer(),
|
||||
precomputedProbabilities: make([]string, 0, 1001),
|
||||
iptablesData: bytes.NewBuffer(nil),
|
||||
@@ -1902,15 +1880,6 @@ COMMIT
|
||||
-A KUBE-SERVICES -m comment --comment "kubernetes service nodeports; NOTE: this must be the last rule in this chain" -m addrtype --dst-type LOCAL -j KUBE-NODEPORTS
|
||||
COMMIT
|
||||
`
|
||||
assert.Equal(t, []*netutils.LocalPort{
|
||||
{
|
||||
Description: "nodePort for ns1/svc1:p80",
|
||||
IP: "",
|
||||
IPFamily: netutils.IPv4,
|
||||
Port: svcNodePort,
|
||||
Protocol: netutils.TCP,
|
||||
},
|
||||
}, fp.portMapper.(*fakePortOpener).openPorts)
|
||||
assertIPTablesRulesEqual(t, expected, fp.iptablesData.String())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user