Skip to content

Commit 7086035

Browse files
committed
Remove routing.recursionBlockDuration and routing.recursionBlockTreads
The rapid-reconnect recursion-block logic in stream_creator.go and the associated config settings are removed. The struct fields are kept for backward-compatible YAML parsing but emit a deprecation warning pointing to the route-controller DaemonSet. Test helpers that disabled the feature via RecursionBlockDuration=0 are cleaned up accordingly. Signed-off-by: Thomas Hallgren <thomas@tada.se>
1 parent 93aa9aa commit 7086035

File tree

6 files changed

+32
-96
lines changed

6 files changed

+32
-96
lines changed

integration_test/itest/cluster.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,6 @@ func (s *cluster) withBasicConfig(c context.Context, t *testing.T) context.Conte
459459
if s.ClientIsVersion(">=2.23.0") {
460460
config.Intercept().MountsRoot = TempDir(c)
461461
}
462-
config.Routing().RecursionBlockDuration = 10 * time.Millisecond
463462
config = config.Merge(client.GetConfig(c))
464463

465464
configYaml, err := config.MarshalYAML()

integration_test/large_files_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,6 @@ func (s *largeFilesSuite) Test_LargeFileIntercepts_sshfs() {
197197
}
198198

199199
func (s *largeFilesSuite) largeFileIntercepts(ctx context.Context) {
200-
ctx = itest.WithConfig(ctx, func(config client.Config) {
201-
config.Routing().RecursionBlockDuration = 0
202-
})
203-
204200
s.createIntercepts(ctx)
205201
wg := sync.WaitGroup{}
206202

integration_test/multiple_services_test.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414

1515
"github.com/telepresenceio/clog"
1616
"github.com/telepresenceio/telepresence/v2/integration_test/itest"
17-
"github.com/telepresenceio/telepresence/v2/pkg/client"
1817
)
1918

2019
type multipleServicesSuite struct {
@@ -36,12 +35,8 @@ func (s *multipleServicesSuite) Test_LargeRequest() {
3635
if !(s.ManagerIsVersion(">2.21.x") && s.ClientIsVersion(">2.21.x")) {
3736
s.T().Skip("Not part of compatibility tests. TUN-device isn't stable enough in versions <2.22.0")
3837
}
39-
// This particular cannot run with recursion detection, because it will trigger on the very high concurrency.
4038
ctx := s.Context()
4139
itest.TelepresenceQuitOk(ctx)
42-
ctx = itest.WithConfig(ctx, func(config client.Config) {
43-
config.Routing().RecursionBlockDuration = 0
44-
})
4540
s.TelepresenceConnect(ctx)
4641
defer func() {
4742
// Restore the connection to what it was before the test.

integration_test/wiretap_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
"github.com/telepresenceio/clog"
1818
"github.com/telepresenceio/telepresence/rpc/v2/connector"
1919
"github.com/telepresenceio/telepresence/v2/integration_test/itest"
20-
"github.com/telepresenceio/telepresence/v2/pkg/client"
2120
)
2221

2322
type wiretapSuite struct {
@@ -106,9 +105,7 @@ func (s *wiretapSuite) startWiretapHandler(ctx context.Context, name, addr strin
106105
}
107106

108107
func (s *wiretapSuite) Test_MultipleTapsOnOnePort() { //nolint:gocognit
109-
ctx := itest.WithConfig(s.Context(), func(config client.Config) {
110-
config.Routing().RecursionBlockDuration = 0
111-
})
108+
ctx := s.Context()
112109
s.TelepresenceConnect(ctx)
113110
defer itest.TelepresenceQuitOk(ctx)
114111

pkg/client/config.go

Lines changed: 31 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,10 @@ func ParseConfigYAML(ctx context.Context, path string, data []byte) (Config, err
229229
}
230230
cfg.Routing().VirtualSubnet = sn
231231
}
232+
if r := cfg.Routing(); r.RecursionBlockDuration > 0 || r.RecursionBlockTreads > 0 {
233+
clog.Warnf(ctx, "routing.recursionBlockDuration and routing.recursionBlockTreads are deprecated and no longer used; "+
234+
"use the route-controller DaemonSet instead (see docs/reference/route-controller.md)")
235+
}
232236
return cfg, nil
233237
}
234238

@@ -991,31 +995,30 @@ func (d *Helm) UnmarshalJSONFrom(in *jsontext.Decoder) error {
991995
}
992996

993997
type Routing struct {
994-
Subnets []netip.Prefix `json:"subnets,omitempty"`
995-
AlsoProxy []netip.Prefix `json:"alsoProxySubnets,omitempty"`
996-
NeverProxy []netip.Prefix `json:"neverProxySubnets,omitempty"`
997-
AllowConflicting []netip.Prefix `json:"allowConflictingSubnets,omitempty"`
998-
RecursionBlockDuration time.Duration `json:"recursionBlockDuration,omitempty,format:units"`
999-
RecursionBlockTreads int `json:"recursionBlockTreads,omitempty"`
1000-
VirtualSubnet netip.Prefix `json:"virtualSubnet"`
1001-
AutoResolveConflicts bool `json:"autoResolveConflicts"`
1002-
UseTAP bool `json:"useTAP"`
998+
Subnets []netip.Prefix `json:"subnets,omitempty"`
999+
AlsoProxy []netip.Prefix `json:"alsoProxySubnets,omitempty"`
1000+
NeverProxy []netip.Prefix `json:"neverProxySubnets,omitempty"`
1001+
AllowConflicting []netip.Prefix `json:"allowConflictingSubnets,omitempty"`
1002+
VirtualSubnet netip.Prefix `json:"virtualSubnet"`
1003+
AutoResolveConflicts bool `json:"autoResolveConflicts"`
1004+
UseTAP bool `json:"useTAP"`
10031005

10041006
// For backward compatibility.
10051007
OldAlsoProxy []netip.Prefix `json:"alsoProxy,omitempty"`
10061008
OldNeverProxy []netip.Prefix `json:"neverProxy,omitempty"`
10071009
OldAllowConflicting []netip.Prefix `json:"allowConflicting,omitempty"`
1010+
1011+
// Deprecated: no longer used. Use the route-controller DaemonSet instead.
1012+
RecursionBlockDuration time.Duration `json:"recursionBlockDuration,omitempty,format:units"`
1013+
// Deprecated: no longer used. Use the route-controller DaemonSet instead.
1014+
RecursionBlockTreads int `json:"recursionBlockTreads,omitempty"`
10081015
}
10091016

1010-
const (
1011-
defaultAutoResolveConflicts = true
1012-
defaultRecursionBlockThreads = 5
1013-
)
1017+
const defaultAutoResolveConflicts = true
10141018

10151019
var defaultRouting = Routing{ //nolint:gochecknoglobals // constant
10161020
VirtualSubnet: defaultVirtualSubnet,
10171021
AutoResolveConflicts: defaultAutoResolveConflicts,
1018-
RecursionBlockTreads: defaultRecursionBlockThreads,
10191022
}
10201023

10211024
func (r *Routing) defaults() DefaultsAware {
@@ -1041,12 +1044,6 @@ func (r *Routing) merge(o *Routing) {
10411044
if len(o.Subnets) > 0 {
10421045
r.Subnets = o.Subnets
10431046
}
1044-
if o.RecursionBlockDuration > 0 {
1045-
r.RecursionBlockDuration = o.RecursionBlockDuration
1046-
}
1047-
if o.RecursionBlockTreads != defaultRecursionBlockThreads {
1048-
r.RecursionBlockTreads = o.RecursionBlockTreads
1049-
}
10501047
if o.VirtualSubnet != defaultVirtualSubnet {
10511048
r.VirtualSubnet = o.VirtualSubnet
10521049
}
@@ -1230,15 +1227,13 @@ func LoadConfig(c context.Context) (cfg Config, err error) {
12301227

12311228
// RoutingSnake is the same as Routing but with snake_case json/yaml names.
12321229
type RoutingSnake struct {
1233-
Subnets []netip.Prefix `json:"subnets"`
1234-
AlsoProxy []netip.Prefix `json:"also_proxy_subnets"`
1235-
NeverProxy []netip.Prefix `json:"never_proxy_subnets"`
1236-
AllowConflicting []netip.Prefix `json:"allow_conflicting_subnets"`
1237-
RecursionBlockDuration time.Duration `json:"recursion_block_duration,format:units"`
1238-
RecursionBlockTreads int `json:"recursion_block_treads"`
1239-
VirtualSubnet netip.Prefix `json:"virtual_subnet"`
1240-
AutoResolveConflicts bool `json:"auto_resolve_conflicts"`
1241-
UseTAP bool `json:"use_tap"`
1230+
Subnets []netip.Prefix `json:"subnets"`
1231+
AlsoProxy []netip.Prefix `json:"also_proxy_subnets"`
1232+
NeverProxy []netip.Prefix `json:"never_proxy_subnets"`
1233+
AllowConflicting []netip.Prefix `json:"allow_conflicting_subnets"`
1234+
VirtualSubnet netip.Prefix `json:"virtual_subnet"`
1235+
AutoResolveConflicts bool `json:"auto_resolve_conflicts"`
1236+
UseTAP bool `json:"use_tap"`
12421237
}
12431238

12441239
// DNSMapping contains a hostname and its associated alias. When requesting the name, the intended behavior is
@@ -1371,15 +1366,13 @@ func MappingsFromRPC(mappings []*daemon.DNSMapping) DNSMappings {
13711366

13721367
func (r *Routing) ToSnake() *RoutingSnake {
13731368
return &RoutingSnake{
1374-
Subnets: r.Subnets,
1375-
AlsoProxy: r.AlsoProxy,
1376-
NeverProxy: r.NeverProxy,
1377-
AllowConflicting: r.AllowConflicting,
1378-
AutoResolveConflicts: r.AutoResolveConflicts,
1379-
RecursionBlockDuration: r.RecursionBlockDuration,
1380-
RecursionBlockTreads: r.RecursionBlockTreads,
1381-
VirtualSubnet: r.VirtualSubnet,
1382-
UseTAP: r.UseTAP,
1369+
Subnets: r.Subnets,
1370+
AlsoProxy: r.AlsoProxy,
1371+
NeverProxy: r.NeverProxy,
1372+
AllowConflicting: r.AllowConflicting,
1373+
AutoResolveConflicts: r.AutoResolveConflicts,
1374+
VirtualSubnet: r.VirtualSubnet,
1375+
UseTAP: r.UseTAP,
13831376
}
13841377
}
13851378

pkg/client/rootd/stream_creator.go

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import (
66
"net/netip"
77
"time"
88

9-
"github.com/puzpuzpuz/xsync/v4"
10-
119
"github.com/telepresenceio/clog"
1210
"github.com/telepresenceio/telepresence/v2/pkg/client"
1311
"github.com/telepresenceio/telepresence/v2/pkg/tunnel"
@@ -30,21 +28,7 @@ func checkRecursion(p types.Proto, ip netip.Addr, sn netip.Prefix) (err error) {
3028
return err
3129
}
3230

33-
type recursiveBlock struct {
34-
start time.Time
35-
count int
36-
timer *time.Timer
37-
}
38-
3931
func (s *session) streamCreator() tunnel.StreamCreator {
40-
var recursionBlockMap *xsync.Map[netip.AddrPort, recursiveBlock]
41-
routing := client.GetConfig(s).Routing()
42-
recursionBlockDuration := routing.RecursionBlockDuration
43-
recursionBlockThreads := routing.RecursionBlockTreads
44-
if recursionBlockDuration != 0 {
45-
recursionBlockMap = xsync.NewMap[netip.AddrPort, recursiveBlock]()
46-
}
47-
4832
return func(c context.Context, id tunnel.ConnID) (tunnel.Stream, error) {
4933
p := id.Protocol()
5034
srcIp := id.SourceAddr()
@@ -72,34 +56,6 @@ func (s *session) streamCreator() tunnel.StreamCreator {
7256
id = tunnel.NewConnID(id.Protocol(), id.Source(), netip.AddrPortFrom(destAddr, mp))
7357
}
7458

75-
if recursionBlockDuration > 0 {
76-
dst := netip.AddrPortFrom(destAddr, id.DestinationPort())
77-
block := false
78-
recursionBlockMap.Compute(dst, func(v recursiveBlock, loaded bool) (recursiveBlock, xsync.ComputeOp) {
79-
if loaded {
80-
if time.Since(v.start) < recursionBlockDuration {
81-
v.count++
82-
if v.count < recursionBlockThreads {
83-
return v, xsync.UpdateOp
84-
}
85-
block = true
86-
}
87-
v.timer.Stop()
88-
return v, xsync.DeleteOp
89-
}
90-
91-
// Ensure deletion in case it's only called once
92-
v.timer = time.AfterFunc(recursionBlockDuration*3, func() {
93-
recursionBlockMap.Delete(dst)
94-
})
95-
v.start = time.Now()
96-
return v, xsync.UpdateOp
97-
})
98-
if block {
99-
return nil, fmt.Errorf("refusing recursive dispatch to %s", dst)
100-
}
101-
}
102-
10359
var err error
10460
var tp tunnel.Provider
10561
if a, ok := s.getAgentVIP(destAddr); ok {

0 commit comments

Comments
 (0)