fix: Fix err check in DialWorkspaceAgentTailnet (#4320)

This commit is contained in:
Mathias Fredriksson 2022-10-03 16:53:11 +03:00 committed by GitHub
parent 78a39a809d
commit 00d0620679
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 10 deletions

View File

@ -331,8 +331,12 @@ func (c *Client) DialWorkspaceAgentTailnet(ctx context.Context, logger slog.Logg
// Need to disable compression to avoid a data-race.
CompressionMode: websocket.CompressionDisabled,
})
if errors.Is(err, context.Canceled) {
return
if err != nil {
if errors.Is(err, context.Canceled) {
return
}
logger.Debug(ctx, "failed to dial", slog.Error(err))
continue
}
if isFirst {
if res.StatusCode == http.StatusConflict {
@ -342,14 +346,6 @@ func (c *Client) DialWorkspaceAgentTailnet(ctx context.Context, logger slog.Logg
isFirst = false
close(first)
}
if err != nil {
logger.Debug(ctx, "failed to dial", slog.Error(err))
continue
}
if isFirst {
isFirst = false
close(first)
}
sendNode, errChan := tailnet.ServeCoordinator(websocket.NetConn(ctx, ws, websocket.MessageBinary), func(node []*tailnet.Node) error {
return conn.UpdateNodes(node)
})