Skip to content

Commit 2fd1a72

Browse files
authored
fix: only delete expired agents on success (#11940)
1 parent 27f3b7a commit 2fd1a72

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

coderd/tailnet.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,13 @@ func (s *ServerTailnet) doExpireOldAgents(cutoff time.Duration) {
206206
// If no one has connected since the cutoff and there are no active
207207
// connections, remove the agent.
208208
if time.Since(lastConnection) > cutoff && len(s.agentTickets[agentID]) == 0 {
209-
deletedCount++
210-
delete(s.agentConnectionTimes, agentID)
211209
err := agentConn.UnsubscribeAgent(agentID)
212210
if err != nil {
213211
s.logger.Error(ctx, "unsubscribe expired agent", slog.Error(err), slog.F("agent_id", agentID))
212+
continue
214213
}
214+
deletedCount++
215+
delete(s.agentConnectionTimes, agentID)
215216
}
216217
}
217218
s.nodesMu.Unlock()

0 commit comments

Comments
 (0)