Skip to content

Commit d3fd581

Browse files
Revert "TUN-6617: Dont fallback to http2 if QUIC conn was successful."
This reverts commit 679a89c.
1 parent 68d370a commit d3fd581

File tree

11 files changed

+87
-133
lines changed

11 files changed

+87
-133
lines changed

connection/control.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package connection
22

33
import (
44
"context"
5-
"fmt"
65
"io"
76
"net"
87
"time"
@@ -22,7 +21,6 @@ type controlStream struct {
2221
namedTunnelProperties *NamedTunnelProperties
2322
connIndex uint8
2423
edgeAddress net.IP
25-
protocol Protocol
2624

2725
newRPCClientFunc RPCClientFunc
2826

@@ -53,7 +51,6 @@ func NewControlStream(
5351
newRPCClientFunc RPCClientFunc,
5452
gracefulShutdownC <-chan struct{},
5553
gracePeriod time.Duration,
56-
protocol Protocol,
5754
) ControlStreamHandler {
5855
if newRPCClientFunc == nil {
5956
newRPCClientFunc = newRegistrationRPCClient
@@ -67,7 +64,6 @@ func NewControlStream(
6764
edgeAddress: edgeAddress,
6865
gracefulShutdownC: gracefulShutdownC,
6966
gracePeriod: gracePeriod,
70-
protocol: protocol,
7167
}
7268
}
7369

@@ -84,9 +80,6 @@ func (c *controlStream) ServeControlStream(
8480
rpcClient.Close()
8581
return err
8682
}
87-
88-
c.observer.logServerInfo(c.connIndex, registrationDetails.Location, c.edgeAddress, fmt.Sprintf("Connection %s registered", registrationDetails.UUID))
89-
c.observer.sendConnectedEvent(c.connIndex, c.protocol, registrationDetails.Location)
9083
c.connectedFuse.Connected()
9184

9285
// if conn index is 0 and tunnel is not remotely managed, then send local ingress rules configuration

connection/event.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ type Event struct {
55
Index uint8
66
EventType Status
77
Location string
8-
Protocol Protocol
98
URL string
109
}
1110

connection/http2_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ func newTestHTTP2Connection() (*HTTP2Connection, net.Conn) {
4343
nil,
4444
nil,
4545
1*time.Second,
46-
HTTP2,
4746
)
4847
return NewHTTP2Connection(
4948
cfdConn,
@@ -367,7 +366,6 @@ func TestServeControlStream(t *testing.T) {
367366
rpcClientFactory.newMockRPCClient,
368367
nil,
369368
1*time.Second,
370-
HTTP2,
371369
)
372370
http2Conn.controlStreamHandler = controlStream
373371

@@ -419,7 +417,6 @@ func TestFailRegistration(t *testing.T) {
419417
rpcClientFactory.newMockRPCClient,
420418
nil,
421419
1*time.Second,
422-
HTTP2,
423420
)
424421
http2Conn.controlStreamHandler = controlStream
425422

@@ -467,7 +464,6 @@ func TestGracefulShutdownHTTP2(t *testing.T) {
467464
rpcClientFactory.newMockRPCClient,
468465
shutdownC,
469466
1*time.Second,
470-
HTTP2,
471467
)
472468

473469
http2Conn.controlStreamHandler = controlStream

connection/observer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ func (o *Observer) sendRegisteringEvent(connIndex uint8) {
5555
o.sendEvent(Event{Index: connIndex, EventType: RegisteringTunnel})
5656
}
5757

58-
func (o *Observer) sendConnectedEvent(connIndex uint8, protocol Protocol, location string) {
59-
o.sendEvent(Event{Index: connIndex, EventType: Connected, Protocol: protocol, Location: location})
58+
func (o *Observer) sendConnectedEvent(connIndex uint8, location string) {
59+
o.sendEvent(Event{Index: connIndex, EventType: Connected, Location: location})
6060
}
6161

6262
func (o *Observer) SendURL(url string) {

connection/quic_test.go

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -81,63 +81,63 @@ func TestQUICServer(t *testing.T) {
8181
},
8282
expectedResponse: []byte("OK"),
8383
},
84-
{
85-
desc: "test http body request streaming",
86-
dest: "/slow_echo_body",
87-
connectionType: quicpogs.ConnectionTypeHTTP,
88-
metadata: []quicpogs.Metadata{
89-
{
90-
Key: "HttpHeader:Cf-Ray",
91-
Val: "123123123",
92-
},
93-
{
94-
Key: "HttpHost",
95-
Val: "cf.host",
96-
},
97-
{
98-
Key: "HttpMethod",
99-
Val: "POST",
100-
},
101-
{
102-
Key: "HttpHeader:Content-Length",
103-
Val: "24",
104-
},
105-
},
106-
message: []byte("This is the message body"),
107-
expectedResponse: []byte("This is the message body"),
108-
},
109-
{
110-
desc: "test ws proxy",
111-
dest: "/ws/echo",
112-
connectionType: quicpogs.ConnectionTypeWebsocket,
113-
metadata: []quicpogs.Metadata{
114-
{
115-
Key: "HttpHeader:Cf-Cloudflared-Proxy-Connection-Upgrade",
116-
Val: "Websocket",
117-
},
118-
{
119-
Key: "HttpHeader:Another-Header",
120-
Val: "Misc",
121-
},
122-
{
123-
Key: "HttpHost",
124-
Val: "cf.host",
125-
},
126-
{
127-
Key: "HttpMethod",
128-
Val: "get",
129-
},
130-
},
131-
message: wsBuf.Bytes(),
132-
expectedResponse: []byte{0x82, 0x5, 0x48, 0x65, 0x6c, 0x6c, 0x6f},
133-
},
134-
{
135-
desc: "test tcp proxy",
136-
connectionType: quicpogs.ConnectionTypeTCP,
137-
metadata: []quicpogs.Metadata{},
138-
message: []byte("Here is some tcp data"),
139-
expectedResponse: []byte("Here is some tcp data"),
140-
},
84+
//{
85+
// desc: "test http body request streaming",
86+
// dest: "/slow_echo_body",
87+
// connectionType: quicpogs.ConnectionTypeHTTP,
88+
// metadata: []quicpogs.Metadata{
89+
// {
90+
// Key: "HttpHeader:Cf-Ray",
91+
// Val: "123123123",
92+
// },
93+
// {
94+
// Key: "HttpHost",
95+
// Val: "cf.host",
96+
// },
97+
// {
98+
// Key: "HttpMethod",
99+
// Val: "POST",
100+
// },
101+
// {
102+
// Key: "HttpHeader:Content-Length",
103+
// Val: "24",
104+
// },
105+
// },
106+
// message: []byte("This is the message body"),
107+
// expectedResponse: []byte("This is the message body"),
108+
//},
109+
//{
110+
// desc: "test ws proxy",
111+
// dest: "/ws/echo",
112+
// connectionType: quicpogs.ConnectionTypeWebsocket,
113+
// metadata: []quicpogs.Metadata{
114+
// {
115+
// Key: "HttpHeader:Cf-Cloudflared-Proxy-Connection-Upgrade",
116+
// Val: "Websocket",
117+
// },
118+
// {
119+
// Key: "HttpHeader:Another-Header",
120+
// Val: "Misc",
121+
// },
122+
// {
123+
// Key: "HttpHost",
124+
// Val: "cf.host",
125+
// },
126+
// {
127+
// Key: "HttpMethod",
128+
// Val: "get",
129+
// },
130+
// },
131+
// message: wsBuf.Bytes(),
132+
// expectedResponse: []byte{0x82, 0x5, 0x48, 0x65, 0x6c, 0x6c, 0x6f},
133+
//},
134+
//{
135+
// desc: "test tcp proxy",
136+
// connectionType: quicpogs.ConnectionTypeTCP,
137+
// metadata: []quicpogs.Metadata{},
138+
// message: []byte("Here is some tcp data"),
139+
// expectedResponse: []byte("Here is some tcp data"),
140+
//},
141141
}
142142

143143
for _, test := range tests {

connection/rpc.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package connection
22

33
import (
44
"context"
5+
"fmt"
56
"io"
67
"net"
78
"time"
@@ -116,6 +117,9 @@ func (rsc *registrationServerClient) RegisterConnection(
116117

117118
observer.metrics.regSuccess.WithLabelValues("registerConnection").Inc()
118119

120+
observer.logServerInfo(connIndex, conn.Location, edgeAddress, fmt.Sprintf("Connection %s registered", conn.UUID))
121+
observer.sendConnectedEvent(connIndex, conn.Location)
122+
119123
return conn, nil
120124
}
121125

metrics/readiness_test.go

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

1515
func TestReadyServer_makeResponse(t *testing.T) {
1616
type fields struct {
17-
isConnected map[uint8]tunnelstate.ConnectionInfo
17+
isConnected map[int]bool
1818
}
1919
tests := []struct {
2020
name string
@@ -25,11 +25,11 @@ func TestReadyServer_makeResponse(t *testing.T) {
2525
{
2626
name: "One connection online => HTTP 200",
2727
fields: fields{
28-
isConnected: map[uint8]tunnelstate.ConnectionInfo{
29-
0: {IsConnected: false},
30-
1: {IsConnected: false},
31-
2: {IsConnected: true},
32-
3: {IsConnected: false},
28+
isConnected: map[int]bool{
29+
0: false,
30+
1: false,
31+
2: true,
32+
3: false,
3333
},
3434
},
3535
wantOK: true,
@@ -38,11 +38,11 @@ func TestReadyServer_makeResponse(t *testing.T) {
3838
{
3939
name: "No connections online => no HTTP 200",
4040
fields: fields{
41-
isConnected: map[uint8]tunnelstate.ConnectionInfo{
42-
0: {IsConnected: false},
43-
1: {IsConnected: false},
44-
2: {IsConnected: false},
45-
3: {IsConnected: false},
41+
isConnected: map[int]bool{
42+
0: false,
43+
1: false,
44+
2: false,
45+
3: false,
4646
},
4747
},
4848
wantReadyConnections: 0,

supervisor/conn_aware_logger.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ type ConnAwareLogger struct {
1212
logger *zerolog.Logger
1313
}
1414

15-
func NewConnAwareLogger(logger *zerolog.Logger, tracker *tunnelstate.ConnTracker, observer *connection.Observer) *ConnAwareLogger {
15+
func NewConnAwareLogger(logger *zerolog.Logger, observer *connection.Observer) *ConnAwareLogger {
1616
connAwareLogger := &ConnAwareLogger{
17-
tracker: tracker,
17+
tracker: tunnelstate.NewConnTracker(logger),
1818
logger: logger,
1919
}
2020

supervisor/supervisor.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
"github.com/cloudflare/cloudflared/retry"
2020
"github.com/cloudflare/cloudflared/signal"
2121
tunnelpogs "github.com/cloudflare/cloudflared/tunnelrpc/pogs"
22-
"github.com/cloudflare/cloudflared/tunnelstate"
2322
)
2423

2524
const (
@@ -89,9 +88,7 @@ func NewSupervisor(config *TunnelConfig, orchestrator *orchestration.Orchestrato
8988
}
9089

9190
reconnectCredentialManager := newReconnectCredentialManager(connection.MetricsNamespace, connection.TunnelSubsystem, config.HAConnections)
92-
93-
tracker := tunnelstate.NewConnTracker(config.Log)
94-
log := NewConnAwareLogger(config.Log, tracker, config.Observer)
91+
log := NewConnAwareLogger(config.Log, config.Observer)
9592

9693
var edgeAddrHandler EdgeAddrHandler
9794
if isStaticEdge { // static edge addresses
@@ -109,7 +106,6 @@ func NewSupervisor(config *TunnelConfig, orchestrator *orchestration.Orchestrato
109106
credentialManager: reconnectCredentialManager,
110107
edgeAddrs: edgeIPs,
111108
edgeAddrHandler: edgeAddrHandler,
112-
tracker: tracker,
113109
reconnectCh: reconnectCh,
114110
gracefulShutdownC: gracefulShutdownC,
115111
connAwareLogger: log,

supervisor/tunnel.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
"github.com/cloudflare/cloudflared/signal"
2727
"github.com/cloudflare/cloudflared/tunnelrpc"
2828
tunnelpogs "github.com/cloudflare/cloudflared/tunnelrpc/pogs"
29-
"github.com/cloudflare/cloudflared/tunnelstate"
3029
)
3130

3231
const (
@@ -191,7 +190,6 @@ type EdgeTunnelServer struct {
191190
edgeAddrs *edgediscovery.Edge
192191
reconnectCh chan ReconnectSignal
193192
gracefulShutdownC <-chan struct{}
194-
tracker *tunnelstate.ConnTracker
195193

196194
connAwareLogger *ConnAwareLogger
197195
}
@@ -274,12 +272,6 @@ func (e EdgeTunnelServer) Serve(ctx context.Context, connIndex uint8, protocolFa
274272
return err
275273
}
276274

277-
// If a single connection has connected with the current protocol, we know we know we don't have to fallback
278-
// to a different protocol.
279-
if e.tracker.HasConnectedWith(e.config.ProtocolSelector.Current()) {
280-
return err
281-
}
282-
283275
if !selectNextProtocol(
284276
connLog.Logger(),
285277
protocolFallback,
@@ -469,7 +461,6 @@ func serveTunnel(
469461
nil,
470462
gracefulShutdownC,
471463
config.GracePeriod,
472-
protocol,
473464
)
474465

475466
switch protocol {

0 commit comments

Comments
 (0)