Skip to content

chore: fix servertailnet test flake #10110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions coderd/tailnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,10 @@ func (s *ServerTailnet) watchAgentUpdates() {

err := s.conn.UpdateNodes(nodes, false)
if err != nil {
if xerrors.Is(err, tailnet.ErrConnClosed) {
s.logger.Warn(context.Background(), "tailnet conn closed, exiting watchAgentUpdates", slog.Error(err))
return
}
s.logger.Error(context.Background(), "update node in server tailnet", slog.Error(err))
return
}
Expand Down
8 changes: 5 additions & 3 deletions tailnet/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ import (
"github.com/coder/coder/v2/cryptorand"
)

var ErrConnClosed = xerrors.New("connection closed")

const (
WorkspaceAgentSSHPort = 1
WorkspaceAgentReconnectingPTYPort = 2
Expand Down Expand Up @@ -496,7 +498,7 @@ func (c *Conn) UpdateNodes(nodes []*Node, replacePeers bool) error {
defer c.mutex.Unlock()

if c.isClosed() {
return xerrors.New("connection closed")
return ErrConnClosed
}

status := c.Status()
Expand Down Expand Up @@ -590,7 +592,7 @@ func (c *Conn) RemovePeer(selector PeerSelector) (deleted bool, err error) {
defer c.mutex.Unlock()

if c.isClosed() {
return false, xerrors.New("connection closed")
return false, ErrConnClosed
}

deleted = false
Expand Down Expand Up @@ -919,7 +921,7 @@ func (c *Conn) Listen(network, addr string) (net.Listener, error) {
c.mutex.Lock()
if c.isClosed() {
c.mutex.Unlock()
return nil, xerrors.New("closed")
return nil, ErrConnClosed
}
if c.listeners == nil {
c.listeners = map[listenKey]*listener{}
Expand Down