mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: remove legacy wsconncache (#11816)
Fixes #8218 Removes `wsconncache` and related "is legacy?" functions and API calls that were used by it. The only leftover is that Agents still use the legacy IP, so that back level clients or workspace proxies can dial them correctly. We should eventually remove this: #11819
This commit is contained in:
@@ -477,19 +477,6 @@ func ServeMultiAgent(c CoordinatorV2, logger slog.Logger, id uuid.UUID) MultiAge
|
||||
reqs, resps := c.Coordinate(ctx, id, id.String(), SingleTailnetTunnelAuth{})
|
||||
m := (&MultiAgent{
|
||||
ID: id,
|
||||
AgentIsLegacyFunc: func(agentID uuid.UUID) bool {
|
||||
if n := c.Node(agentID); n == nil {
|
||||
// If we don't have the node at all assume it's legacy for
|
||||
// safety.
|
||||
return true
|
||||
} else if len(n.Addresses) > 0 && n.Addresses[0].Addr() == legacyAgentIP {
|
||||
// An agent is determined to be "legacy" if it's first IP is the
|
||||
// legacy IP. Agents with only the legacy IP aren't compatible
|
||||
// with single_tailnet and must be routed through wsconncache.
|
||||
return true
|
||||
}
|
||||
return false
|
||||
},
|
||||
OnSubscribe: func(enq Queue, agent uuid.UUID) error {
|
||||
err := SendCtx(ctx, reqs, &proto.CoordinateRequest{AddTunnel: &proto.CoordinateRequest_Tunnel{Id: UUIDToByteSlice(agent)}})
|
||||
return err
|
||||
@@ -834,10 +821,6 @@ func ServeAgentV1(ctx context.Context, logger slog.Logger, c CoordinatorV2, conn
|
||||
return nil
|
||||
}
|
||||
|
||||
// This is copied from codersdk because importing it here would cause an import
|
||||
// cycle. This is just temporary until wsconncache is phased out.
|
||||
var legacyAgentIP = netip.MustParseAddr("fd7a:115c:a1e0:49d6:b259:b7ac:b1b2:48f4")
|
||||
|
||||
// Close closes all of the open connections in the coordinator and stops the
|
||||
// coordinator from accepting new connections.
|
||||
func (c *coordinator) Close() error {
|
||||
|
||||
+4
-10
@@ -17,7 +17,6 @@ type MultiAgentConn interface {
|
||||
SubscribeAgent(agentID uuid.UUID) error
|
||||
UnsubscribeAgent(agentID uuid.UUID) error
|
||||
NextUpdate(ctx context.Context) (*proto.CoordinateResponse, bool)
|
||||
AgentIsLegacy(agentID uuid.UUID) bool
|
||||
Close() error
|
||||
IsClosed() bool
|
||||
}
|
||||
@@ -27,11 +26,10 @@ type MultiAgent struct {
|
||||
|
||||
ID uuid.UUID
|
||||
|
||||
AgentIsLegacyFunc func(agentID uuid.UUID) bool
|
||||
OnSubscribe func(enq Queue, agent uuid.UUID) error
|
||||
OnUnsubscribe func(enq Queue, agent uuid.UUID) error
|
||||
OnNodeUpdate func(id uuid.UUID, node *proto.Node) error
|
||||
OnRemove func(enq Queue)
|
||||
OnSubscribe func(enq Queue, agent uuid.UUID) error
|
||||
OnUnsubscribe func(enq Queue, agent uuid.UUID) error
|
||||
OnNodeUpdate func(id uuid.UUID, node *proto.Node) error
|
||||
OnRemove func(enq Queue)
|
||||
|
||||
ctx context.Context
|
||||
ctxCancel func()
|
||||
@@ -61,10 +59,6 @@ func (m *MultiAgent) UniqueID() uuid.UUID {
|
||||
return m.ID
|
||||
}
|
||||
|
||||
func (m *MultiAgent) AgentIsLegacy(agentID uuid.UUID) bool {
|
||||
return m.AgentIsLegacyFunc(agentID)
|
||||
}
|
||||
|
||||
var ErrMultiAgentClosed = xerrors.New("multiagent is closed")
|
||||
|
||||
func (m *MultiAgent) UpdateSelf(node *proto.Node) error {
|
||||
|
||||
@@ -41,20 +41,6 @@ func (m *MockMultiAgentConn) EXPECT() *MockMultiAgentConnMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// AgentIsLegacy mocks base method.
|
||||
func (m *MockMultiAgentConn) AgentIsLegacy(arg0 uuid.UUID) bool {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "AgentIsLegacy", arg0)
|
||||
ret0, _ := ret[0].(bool)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// AgentIsLegacy indicates an expected call of AgentIsLegacy.
|
||||
func (mr *MockMultiAgentConnMockRecorder) AgentIsLegacy(arg0 any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AgentIsLegacy", reflect.TypeOf((*MockMultiAgentConn)(nil).AgentIsLegacy), arg0)
|
||||
}
|
||||
|
||||
// Close mocks base method.
|
||||
func (m *MockMultiAgentConn) Close() error {
|
||||
m.ctrl.T.Helper()
|
||||
|
||||
Reference in New Issue
Block a user