From 2fd1a726aa42730a0ab8531507c4f0ed836eb510 Mon Sep 17 00:00:00 2001 From: Colin Adler Date: Tue, 30 Jan 2024 14:11:45 -0600 Subject: [PATCH] fix: only delete expired agents on success (#11940) --- coderd/tailnet.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/coderd/tailnet.go b/coderd/tailnet.go index 076d36cec2..7a2ff9afc4 100644 --- a/coderd/tailnet.go +++ b/coderd/tailnet.go @@ -206,12 +206,13 @@ func (s *ServerTailnet) doExpireOldAgents(cutoff time.Duration) { // If no one has connected since the cutoff and there are no active // connections, remove the agent. if time.Since(lastConnection) > cutoff && len(s.agentTickets[agentID]) == 0 { - deletedCount++ - delete(s.agentConnectionTimes, agentID) err := agentConn.UnsubscribeAgent(agentID) if err != nil { s.logger.Error(ctx, "unsubscribe expired agent", slog.Error(err), slog.F("agent_id", agentID)) + continue } + deletedCount++ + delete(s.agentConnectionTimes, agentID) } } s.nodesMu.Unlock()