feat: modify coordinators to send errors and peers to log them (#17467)

Adds support to our coordinator implementations to send Error updates before disconnecting clients.

I was recently debugging a connection issue where the client was getting repeatedly disconnected from the Coordinator, but since we never send any error information it was really hard without server logs.

This PR aims to correct that, by sending a CoordinateResponse with `Error` set in cases where we disconnect a client without them asking us to.

It also logs the error whenever we get one in the client controller.
This commit is contained in:
Spike Curtis
2025-04-21 11:40:56 +04:00
committed by GitHub
parent ea017a1de8
commit 345435a04c
12 changed files with 135 additions and 51 deletions

View File

@ -58,7 +58,8 @@ func TestCoordinator(t *testing.T) {
},
PreferredDerp: 10,
})
client.AssertEventuallyResponsesClosed()
client.AssertEventuallyResponsesClosed(
tailnet.AuthorizationError{Wrapped: tailnet.InvalidAddressBitsError{Bits: 64}}.Error())
})
t.Run("AgentWithoutClients", func(t *testing.T) {
@ -95,13 +96,13 @@ func TestCoordinator(t *testing.T) {
}()
agent := test.NewAgent(ctx, t, coordinator, "agent")
defer agent.Close(ctx)
prefix := tailnet.TailscaleServicePrefix.RandomPrefix()
agent.UpdateNode(&proto.Node{
Addresses: []string{
tailnet.TailscaleServicePrefix.RandomPrefix().String(),
},
Addresses: []string{prefix.String()},
PreferredDerp: 10,
})
agent.AssertEventuallyResponsesClosed()
agent.AssertEventuallyResponsesClosed(
tailnet.AuthorizationError{Wrapped: tailnet.InvalidNodeAddressError{Addr: prefix.Addr().String()}}.Error())
})
t.Run("AgentWithoutClients_InvalidBits", func(t *testing.T) {
@ -122,7 +123,8 @@ func TestCoordinator(t *testing.T) {
},
PreferredDerp: 10,
})
agent.AssertEventuallyResponsesClosed()
agent.AssertEventuallyResponsesClosed(
tailnet.AuthorizationError{Wrapped: tailnet.InvalidAddressBitsError{Bits: 64}}.Error())
})
t.Run("AgentWithClient", func(t *testing.T) {
@ -198,7 +200,7 @@ func TestCoordinator(t *testing.T) {
agent2.AssertEventuallyHasDERP(client.ID, 2)
// This original agent channels should've been closed forcefully.
agent1.AssertEventuallyResponsesClosed()
agent1.AssertEventuallyResponsesClosed(tailnet.CloseErrOverwritten)
})
t.Run("AgentAck", func(t *testing.T) {