Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd3983e4

Browse files
authored
feat: add logging to client tailnet yamux (#11908)
Adds logging to yamux when used for tailnet client connections, e.g. CLI and wsproxy. This could be useful for debugging connection issues with tailnet v2 API.
1 parent0eff646 commitd3983e4

File tree

5 files changed

+15
-8
lines changed

5 files changed

+15
-8
lines changed

‎codersdk/workspaceagents.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,10 @@ func (tac *tailnetAPIConnector) dial() (proto.DRPCTailnetClient, error) {
436436
}
437437
returnnil,err
438438
}
439-
client,err:=tailnet.NewDRPCClient(websocket.NetConn(tac.ctx,ws,websocket.MessageBinary))
439+
client,err:=tailnet.NewDRPCClient(
440+
websocket.NetConn(tac.ctx,ws,websocket.MessageBinary),
441+
tac.logger,
442+
)
440443
iferr!=nil {
441444
tac.logger.Debug(tac.ctx,"failed to create DRPCClient",slog.Error(err))
442445
_=ws.Close(websocket.StatusInternalError,"")

‎enterprise/wsproxy/wsproxysdk/wsproxysdk.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ func (c *Client) DialCoordinator(ctx context.Context) (agpl.MultiAgentConn, erro
458458
gohttpapi.HeartbeatClose(ctx,logger,cancel,conn)
459459

460460
nc:=websocket.NetConn(ctx,conn,websocket.MessageBinary)
461-
client,err:=agpl.NewDRPCClient(nc)
461+
client,err:=agpl.NewDRPCClient(nc,logger)
462462
iferr!=nil {
463463
logger.Debug(ctx,"failed to create DRPCClient",slog.Error(err))
464464
_=conn.Close(websocket.StatusInternalError,"")
@@ -488,7 +488,9 @@ func (c *Client) DialCoordinator(ctx context.Context) (agpl.MultiAgentConn, erro
488488

489489
gofunc() {
490490
<-ctx.Done()
491-
ma.Close()
491+
_=ma.Close()
492+
_=client.DRPCConn().Close()
493+
<-client.DRPCConn().Closed()
492494
_=conn.Close(websocket.StatusGoingAway,"closed")
493495
}()
494496

‎tailnet/client.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
package tailnet
22

33
import (
4-
"io"
4+
"context"
55
"net"
66

77
"github.com/hashicorp/yamux"
88
"golang.org/x/xerrors"
99

10+
"cdr.dev/slog"
1011
"github.com/coder/coder/v2/codersdk/drpc"
1112
"github.com/coder/coder/v2/tailnet/proto"
1213
)
1314

14-
funcNewDRPCClient(conn net.Conn) (proto.DRPCTailnetClient,error) {
15+
funcNewDRPCClient(conn net.Conn,logger slog.Logger) (proto.DRPCTailnetClient,error) {
1516
config:=yamux.DefaultConfig()
16-
config.LogOutput=io.Discard
17+
config.LogOutput=nil
18+
config.Logger=slog.Stdlib(context.Background(),logger,slog.LevelInfo)
1719
session,err:=yamux.Client(conn,config)
1820
iferr!=nil {
1921
returnnil,xerrors.Errorf("multiplex client: %w",err)

‎tailnet/coordinator_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ func TestRemoteCoordination(t *testing.T) {
464464
serveErr<-err
465465
}()
466466

467-
client,err:=tailnet.NewDRPCClient(cC)
467+
client,err:=tailnet.NewDRPCClient(cC,logger)
468468
require.NoError(t,err)
469469
protocol,err:=client.Coordinate(ctx)
470470
require.NoError(t,err)

‎tailnet/service_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func TestClientService_ServeClient_V2(t *testing.T) {
5151
errCh<-err
5252
}()
5353

54-
client,err:=tailnet.NewDRPCClient(c)
54+
client,err:=tailnet.NewDRPCClient(c,logger)
5555
require.NoError(t,err)
5656

5757
// Coordinate

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp