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

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