mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 20:53:33 +00:00
Merge pull request #77056 from tedyu/cidr
Follow on for Store parsed CIDRs at initialization of Proxier #76779
This commit is contained in:
commit
2b4f18d36d
@ -274,15 +274,17 @@ func (r *realIPGetter) NodeIPs() (ips []net.IP, err error) {
|
|||||||
// Proxier implements ProxyProvider
|
// Proxier implements ProxyProvider
|
||||||
var _ proxy.ProxyProvider = &Proxier{}
|
var _ proxy.ProxyProvider = &Proxier{}
|
||||||
|
|
||||||
// ParseExcludedCIDRs parses the input strings and returns net.IPNet
|
// parseExcludedCIDRs parses the input strings and returns net.IPNet
|
||||||
// The validation has been done earlier so the error condition will never happen under normal conditions
|
// The validation has been done earlier so the error condition will never happen under normal conditions
|
||||||
func ParseExcludedCIDRs(excludeCIDRStrs []string) []*net.IPNet {
|
func parseExcludedCIDRs(excludeCIDRs []string) []*net.IPNet {
|
||||||
var cidrExclusions []*net.IPNet
|
var cidrExclusions []*net.IPNet
|
||||||
for _, excludedCIDR := range excludeCIDRStrs {
|
for _, excludedCIDR := range excludeCIDRs {
|
||||||
_, n, err := net.ParseCIDR(excludedCIDR)
|
_, n, err := net.ParseCIDR(excludedCIDR)
|
||||||
if err == nil {
|
if err != nil {
|
||||||
cidrExclusions = append(cidrExclusions, n)
|
klog.Errorf("Error parsing exclude CIDR %q, err: %v", excludedCIDR, err)
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
cidrExclusions = append(cidrExclusions, n)
|
||||||
}
|
}
|
||||||
return cidrExclusions
|
return cidrExclusions
|
||||||
}
|
}
|
||||||
@ -299,7 +301,7 @@ func NewProxier(ipt utiliptables.Interface,
|
|||||||
exec utilexec.Interface,
|
exec utilexec.Interface,
|
||||||
syncPeriod time.Duration,
|
syncPeriod time.Duration,
|
||||||
minSyncPeriod time.Duration,
|
minSyncPeriod time.Duration,
|
||||||
excludeCIDRStrs []string,
|
excludeCIDRs []string,
|
||||||
strictARP bool,
|
strictARP bool,
|
||||||
masqueradeAll bool,
|
masqueradeAll bool,
|
||||||
masqueradeBit int,
|
masqueradeBit int,
|
||||||
@ -410,7 +412,7 @@ func NewProxier(ipt utiliptables.Interface,
|
|||||||
endpointsChanges: proxy.NewEndpointChangeTracker(hostname, nil, &isIPv6, recorder),
|
endpointsChanges: proxy.NewEndpointChangeTracker(hostname, nil, &isIPv6, recorder),
|
||||||
syncPeriod: syncPeriod,
|
syncPeriod: syncPeriod,
|
||||||
minSyncPeriod: minSyncPeriod,
|
minSyncPeriod: minSyncPeriod,
|
||||||
excludeCIDRs: ParseExcludedCIDRs(excludeCIDRStrs),
|
excludeCIDRs: parseExcludedCIDRs(excludeCIDRs),
|
||||||
iptables: ipt,
|
iptables: ipt,
|
||||||
masqueradeAll: masqueradeAll,
|
masqueradeAll: masqueradeAll,
|
||||||
masqueradeMark: masqueradeMark,
|
masqueradeMark: masqueradeMark,
|
||||||
|
@ -2823,7 +2823,7 @@ func TestCleanLegacyService(t *testing.T) {
|
|||||||
ipt := iptablestest.NewFake()
|
ipt := iptablestest.NewFake()
|
||||||
ipvs := ipvstest.NewFake()
|
ipvs := ipvstest.NewFake()
|
||||||
ipset := ipsettest.NewFake(testIPSetVersion)
|
ipset := ipsettest.NewFake(testIPSetVersion)
|
||||||
fp := NewFakeProxier(ipt, ipvs, ipset, nil, ParseExcludedCIDRs([]string{"3.3.3.0/24", "4.4.4.0/24"}))
|
fp := NewFakeProxier(ipt, ipvs, ipset, nil, parseExcludedCIDRs([]string{"3.3.3.0/24", "4.4.4.0/24"}))
|
||||||
|
|
||||||
// All ipvs services that were processed in the latest sync loop.
|
// All ipvs services that were processed in the latest sync loop.
|
||||||
activeServices := map[string]bool{"ipvs0": true, "ipvs1": true}
|
activeServices := map[string]bool{"ipvs0": true, "ipvs1": true}
|
||||||
@ -2930,7 +2930,7 @@ func TestCleanLegacyRealServersExcludeCIDRs(t *testing.T) {
|
|||||||
ipvs := ipvstest.NewFake()
|
ipvs := ipvstest.NewFake()
|
||||||
ipset := ipsettest.NewFake(testIPSetVersion)
|
ipset := ipsettest.NewFake(testIPSetVersion)
|
||||||
gtm := NewGracefulTerminationManager(ipvs)
|
gtm := NewGracefulTerminationManager(ipvs)
|
||||||
fp := NewFakeProxier(ipt, ipvs, ipset, nil, ParseExcludedCIDRs([]string{"4.4.4.4/32"}))
|
fp := NewFakeProxier(ipt, ipvs, ipset, nil, parseExcludedCIDRs([]string{"4.4.4.4/32"}))
|
||||||
fp.gracefuldeleteManager = gtm
|
fp.gracefuldeleteManager = gtm
|
||||||
|
|
||||||
vs := &utilipvs.VirtualServer{
|
vs := &utilipvs.VirtualServer{
|
||||||
@ -2984,7 +2984,7 @@ func TestCleanLegacyService6(t *testing.T) {
|
|||||||
ipt := iptablestest.NewFake()
|
ipt := iptablestest.NewFake()
|
||||||
ipvs := ipvstest.NewFake()
|
ipvs := ipvstest.NewFake()
|
||||||
ipset := ipsettest.NewFake(testIPSetVersion)
|
ipset := ipsettest.NewFake(testIPSetVersion)
|
||||||
fp := NewFakeProxier(ipt, ipvs, ipset, nil, ParseExcludedCIDRs([]string{"3000::/64", "4000::/64"}))
|
fp := NewFakeProxier(ipt, ipvs, ipset, nil, parseExcludedCIDRs([]string{"3000::/64", "4000::/64"}))
|
||||||
fp.nodeIP = net.ParseIP("::1")
|
fp.nodeIP = net.ParseIP("::1")
|
||||||
|
|
||||||
// All ipvs services that were processed in the latest sync loop.
|
// All ipvs services that were processed in the latest sync loop.
|
||||||
|
Loading…
Reference in New Issue
Block a user