Skip to content

Commit befa9cb

Browse files
committed
only warn on ready for handshake errors
1 parent 9cc149f commit befa9cb

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

enterprise/tailnet/connio.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ func (c *connIO) handleRequest(req *proto.CoordinateRequest) error {
221221
slog.F("dst", dst.String()),
222222
)
223223
_ = c.Enqueue(&proto.CoordinateResponse{
224-
Error: fmt.Sprintf("you do not share a tunnel with %q", dst.String()),
224+
Error: fmt.Sprintf("%s: you do not share a tunnel with %q", agpl.ReadyForHandshakeError, dst.String()),
225225
})
226226
return nil
227227
}

tailnet/controllers.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,14 @@ func (c *BasicCoordination) respLoop() {
285285
}
286286

287287
if resp.Error != "" {
288-
c.logger.Error(context.Background(),
289-
"coordination protocol error", slog.F("error", resp.Error))
288+
// ReadyForHandshake error can occur during race conditions, where we send a ReadyForHandshake message,
289+
// but the source has already disconnected from the tunnel by the time we do. So, just log at warning.
290+
if strings.HasPrefix(resp.Error, ReadyForHandshakeError) {
291+
c.logger.Warn(context.Background(), "coordination warning", slog.F("msg", resp.Error))
292+
} else {
293+
c.logger.Error(context.Background(),
294+
"coordination protocol error", slog.F("error", resp.Error))
295+
}
290296
}
291297

292298
err = c.coordinatee.UpdatePeers(resp.GetPeerUpdates())

tailnet/coordinator.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const (
2727
RequestBufferSize = 32
2828
CloseErrOverwritten = "peer ID overwritten by new connection"
2929
CloseErrCoordinatorClose = "coordinator closed"
30+
ReadyForHandshakeError = "ready for handshake error"
3031
)
3132

3233
// Coordinator exchanges nodes with agents to establish connections.
@@ -316,7 +317,7 @@ func (c *core) handleReadyForHandshakeLocked(src *peer, rfhs []*proto.Coordinate
316317
// don't want to kill its connection.
317318
select {
318319
case src.resps <- &proto.CoordinateResponse{
319-
Error: fmt.Sprintf("you do not share a tunnel with %q", dstID.String()),
320+
Error: fmt.Sprintf("%s: you do not share a tunnel with %q", ReadyForHandshakeError, dstID.String()),
320321
}:
321322
default:
322323
return ErrWouldBlock

0 commit comments

Comments
 (0)