Skip to content

Commit ed2ba52

Browse files
committed
chore: refactor ServerTailnet to use tailnet.Controllers
1 parent 791e183 commit ed2ba52

20 files changed

+463
-1226
lines changed

Makefile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,6 @@ gen: \
507507
examples/examples.gen.json \
508508
tailnet/tailnettest/coordinatormock.go \
509509
tailnet/tailnettest/coordinateemock.go \
510-
tailnet/tailnettest/multiagentmock.go \
511510
coderd/database/pubsub/psmock/psmock.go
512511
.PHONY: gen
513512

@@ -537,7 +536,6 @@ gen/mark-fresh:
537536
examples/examples.gen.json \
538537
tailnet/tailnettest/coordinatormock.go \
539538
tailnet/tailnettest/coordinateemock.go \
540-
tailnet/tailnettest/multiagentmock.go \
541539
coderd/database/pubsub/psmock/psmock.go \
542540
"
543541

@@ -570,7 +568,7 @@ coderd/database/dbmock/dbmock.go: coderd/database/db.go coderd/database/querier.
570568
coderd/database/pubsub/psmock/psmock.go: coderd/database/pubsub/pubsub.go
571569
go generate ./coderd/database/pubsub/psmock
572570

573-
tailnet/tailnettest/coordinatormock.go tailnet/tailnettest/multiagentmock.go tailnet/tailnettest/coordinateemock.go: tailnet/coordinator.go tailnet/multiagent.go
571+
tailnet/tailnettest/coordinatormock.go tailnet/tailnettest/coordinateemock.go: tailnet/coordinator.go
574572
go generate ./tailnet/tailnettest/
575573

576574
tailnet/proto/tailnet.pb.go: tailnet/proto/tailnet.proto

agent/agent_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1919,7 +1919,8 @@ func TestAgent_UpdatedDERP(t *testing.T) {
19191919
t.Cleanup(testCtxCancel)
19201920
clientID := uuid.New()
19211921
ctrl := tailnet.NewSingleDestController(logger, conn, agentID)
1922-
coordination := ctrl.New(tailnet.NewInMemoryCoordinatorClient(logger, clientID, agentID, coordinator))
1922+
auth := tailnet.ClientCoordinateeAuth{AgentID: agentID}
1923+
coordination := ctrl.New(tailnet.NewInMemoryCoordinatorClient(logger, clientID, auth, coordinator))
19231924
t.Cleanup(func() {
19241925
t.Logf("closing coordination %s", name)
19251926
cctx, ccancel := context.WithTimeout(testCtx, testutil.WaitShort)
@@ -2408,8 +2409,9 @@ func setupAgent(t *testing.T, metadata agentsdk.Manifest, ptyTimeout time.Durati
24082409
t.Cleanup(testCtxCancel)
24092410
clientID := uuid.New()
24102411
ctrl := tailnet.NewSingleDestController(logger, conn, metadata.AgentID)
2412+
auth := tailnet.ClientCoordinateeAuth{AgentID: metadata.AgentID}
24112413
coordination := ctrl.New(tailnet.NewInMemoryCoordinatorClient(
2412-
logger, clientID, metadata.AgentID, coordinator))
2414+
logger, clientID, auth, coordinator))
24132415
t.Cleanup(func() {
24142416
cctx, ccancel := context.WithTimeout(testCtx, testutil.WaitShort)
24152417
defer ccancel()

coderd/coderd.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -627,14 +627,17 @@ func New(options *Options) *API {
627627

628628
api.Auditor.Store(&options.Auditor)
629629
api.TailnetCoordinator.Store(&options.TailnetCoordinator)
630+
dialer := &InmemTailnetDialer{
631+
CoordPtr: &api.TailnetCoordinator,
632+
DERPFn: api.DERPMap,
633+
Logger: options.Logger,
634+
ClientID: uuid.New(),
635+
}
630636
stn, err := NewServerTailnet(api.ctx,
631637
options.Logger,
632638
options.DERPServer,
633-
api.DERPMap,
639+
dialer,
634640
options.DeploymentValues.DERP.Config.ForceWebSockets.Value(),
635-
func(context.Context) (tailnet.MultiAgentConn, error) {
636-
return (*api.TailnetCoordinator.Load()).ServeMultiAgent(uuid.New()), nil
637-
},
638641
options.DeploymentValues.DERP.Config.BlockDirect.Value(),
639642
api.TracerProvider,
640643
)

0 commit comments

Comments
 (0)