TUN-6720: Remove forcibly closing connection during reconnect signal

Previously allowing the reconnect signal forcibly close the connection
caused a race condition on which error was returned by the errgroup
in the tunnel connection. Allowing the signal to return and provide
a context cancel to the connection provides a safer shutdown of the
tunnel for this test-only scenario.
This commit is contained in:
Devin Carr
2022-08-31 12:52:44 -07:00
parent 8ec0f7746b
commit cfef0e737f
5 changed files with 22 additions and 19 deletions

View File

@@ -546,7 +546,13 @@ func (e *EdgeTunnelServer) serveH2mux(
})
errGroup.Go(func() error {
return listenReconnect(serveCtx, e.reconnectCh, e.gracefulShutdownC)
err := listenReconnect(serveCtx, e.reconnectCh, e.gracefulShutdownC)
if err != nil {
// forcefully break the connection (this is only used for testing)
// errgroup will return context canceled for the handler.ServeClassicTunnel
connLog.Logger().Debug().Msg("Forcefully breaking h2mux connection")
}
return err
})
return errGroup.Wait()
@@ -580,8 +586,8 @@ func (e *EdgeTunnelServer) serveHTTP2(
err := listenReconnect(serveCtx, e.reconnectCh, e.gracefulShutdownC)
if err != nil {
// forcefully break the connection (this is only used for testing)
// errgroup will return context canceled for the h2conn.Serve
connLog.Logger().Debug().Msg("Forcefully breaking http2 connection")
_ = tlsServerConn.Close()
}
return err
})
@@ -636,8 +642,8 @@ func (e *EdgeTunnelServer) serveQUIC(
err := listenReconnect(serveCtx, e.reconnectCh, e.gracefulShutdownC)
if err != nil {
// forcefully break the connection (this is only used for testing)
// errgroup will return context canceled for the quicConn.Serve
connLogger.Logger().Debug().Msg("Forcefully breaking quic connection")
quicConn.Close()
}
return err
})