Skip to content

Commit c954663

Browse files
committed
fixup! feat: add single tailnet support to pgcoord
1 parent 4a4bbdb commit c954663

File tree

4 files changed

+16
-9
lines changed

4 files changed

+16
-9
lines changed

enterprise/coderd/workspaceproxycoordinate.go

+8
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ func (api *API) workspaceProxyCoordinate(rw http.ResponseWriter, r *http.Request
6868

6969
id := uuid.New()
7070
sub, err := (*api.AGPL.TailnetCoordinator.Load()).ServeMultiAgent(id)
71+
if err != nil {
72+
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
73+
Message: "Failed to serve multi agent.",
74+
Detail: err.Error(),
75+
})
76+
return
77+
}
78+
7179
nc := websocket.NetConn(ctx, conn, websocket.MessageText)
7280
defer nc.Close()
7381

enterprise/wsproxy/wsproxysdk/wsproxysdk.go

+8-9
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
"github.com/coder/coder/v2/coderd/httpmw"
2323
"github.com/coder/coder/v2/coderd/workspaceapps"
2424
"github.com/coder/coder/v2/codersdk"
25-
"github.com/coder/coder/v2/tailnet"
2625
agpl "github.com/coder/coder/v2/tailnet"
2726
)
2827

@@ -423,14 +422,14 @@ const (
423422
type CoordinateMessage struct {
424423
Type CoordinateMessageType `json:"type"`
425424
AgentID uuid.UUID `json:"agent_id"`
426-
Node *tailnet.Node `json:"node"`
425+
Node *agpl.Node `json:"node"`
427426
}
428427

429428
type CoordinateNodes struct {
430-
Nodes []*tailnet.Node
429+
Nodes []*agpl.Node
431430
}
432431

433-
func (c *Client) DialCoordinator(ctx context.Context) (tailnet.MultiAgentConn, error) {
432+
func (c *Client) DialCoordinator(ctx context.Context) (agpl.MultiAgentConn, error) {
434433
ctx, cancel := context.WithCancel(ctx)
435434

436435
coordinateURL, err := c.SDKClient.URL.Parse("/api/v2/workspaceproxies/me/coordinate")
@@ -464,7 +463,7 @@ func (c *Client) DialCoordinator(ctx context.Context) (tailnet.MultiAgentConn, e
464463
legacyAgentCache: map[uuid.UUID]bool{},
465464
}
466465

467-
ma := (&tailnet.MultiAgent{
466+
ma := (&agpl.MultiAgent{
468467
ID: uuid.New(),
469468
AgentIsLegacyFunc: rma.AgentIsLegacy,
470469
OnSubscribe: rma.OnSubscribe,
@@ -516,7 +515,7 @@ func (a *remoteMultiAgentHandler) writeJSON(v interface{}) error {
516515

517516
// Set a deadline so that hung connections don't put back pressure on the system.
518517
// Node updates are tiny, so even the dinkiest connection can handle them if it's not hung.
519-
err = a.nc.SetWriteDeadline(time.Now().Add(tailnet.WriteTimeout))
518+
err = a.nc.SetWriteDeadline(time.Now().Add(agpl.WriteTimeout))
520519
if err != nil {
521520
return xerrors.Errorf("set write deadline: %w", err)
522521
}
@@ -538,21 +537,21 @@ func (a *remoteMultiAgentHandler) writeJSON(v interface{}) error {
538537
return nil
539538
}
540539

541-
func (a *remoteMultiAgentHandler) OnNodeUpdate(_ uuid.UUID, node *tailnet.Node) error {
540+
func (a *remoteMultiAgentHandler) OnNodeUpdate(_ uuid.UUID, node *agpl.Node) error {
542541
return a.writeJSON(CoordinateMessage{
543542
Type: CoordinateMessageTypeNodeUpdate,
544543
Node: node,
545544
})
546545
}
547546

548-
func (a *remoteMultiAgentHandler) OnSubscribe(_ tailnet.Queue, agentID uuid.UUID) (*tailnet.Node, error) {
547+
func (a *remoteMultiAgentHandler) OnSubscribe(_ agpl.Queue, agentID uuid.UUID) (*agpl.Node, error) {
549548
return nil, a.writeJSON(CoordinateMessage{
550549
Type: CoordinateMessageTypeSubscribe,
551550
AgentID: agentID,
552551
})
553552
}
554553

555-
func (a *remoteMultiAgentHandler) OnUnsubscribe(_ tailnet.Queue, agentID uuid.UUID) error {
554+
func (a *remoteMultiAgentHandler) OnUnsubscribe(_ agpl.Queue, agentID uuid.UUID) error {
556555
return a.writeJSON(CoordinateMessage{
557556
Type: CoordinateMessageTypeUnsubscribe,
558557
AgentID: agentID,

0 commit comments

Comments
 (0)