mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
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:
@@ -22,7 +22,7 @@ func GracefulDisconnectTest(ctx context.Context, t *testing.T, coordinator tailn
|
||||
|
||||
p2.Disconnect()
|
||||
p1.AssertEventuallyDisconnected(p2.ID)
|
||||
p2.AssertEventuallyResponsesClosed()
|
||||
p2.AssertEventuallyResponsesClosed("")
|
||||
}
|
||||
|
||||
func LostTest(ctx context.Context, t *testing.T, coordinator tailnet.CoordinatorV2) {
|
||||
|
||||
@@ -230,13 +230,21 @@ func (p *Peer) AssertEventuallyLost(other uuid.UUID) {
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Peer) AssertEventuallyResponsesClosed() {
|
||||
func (p *Peer) AssertEventuallyResponsesClosed(expectedError string) {
|
||||
gotErr := false
|
||||
p.t.Helper()
|
||||
for {
|
||||
err := p.readOneResp()
|
||||
if xerrors.Is(err, errResponsesClosed) {
|
||||
if !gotErr && expectedError != "" {
|
||||
p.t.Errorf("responses closed without error '%s'", expectedError)
|
||||
}
|
||||
return
|
||||
}
|
||||
if err != nil && expectedError != "" && err.Error() == expectedError {
|
||||
gotErr = true
|
||||
continue
|
||||
}
|
||||
if !assert.NoError(p.t, err) {
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user