mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
fix(coderd): Ensure agent disconnect happens after timeout (#6600)
Fixes #6598
This commit is contained in:
committed by
GitHub
parent
7587850a1c
commit
348530000f
@ -175,6 +175,10 @@ func New(options *Options) *API {
|
||||
if options.AgentInactiveDisconnectTimeout == 0 {
|
||||
// Multiply the update by two to allow for some lag-time.
|
||||
options.AgentInactiveDisconnectTimeout = options.AgentConnectionUpdateFrequency * 2
|
||||
// Set a minimum timeout to avoid disconnecting too soon.
|
||||
if options.AgentInactiveDisconnectTimeout < 2*time.Second {
|
||||
options.AgentInactiveDisconnectTimeout = 2 * time.Second
|
||||
}
|
||||
}
|
||||
if options.AgentStatsRefreshInterval == 0 {
|
||||
options.AgentStatsRefreshInterval = 5 * time.Minute
|
||||
|
@ -615,7 +615,7 @@ func (api *API) workspaceAgentCoordinate(rw http.ResponseWriter, r *http.Request
|
||||
|
||||
// We use a custom heartbeat routine here instead of `httpapi.Heartbeat`
|
||||
// because we want to log the agent's last ping time.
|
||||
var lastPing time.Time
|
||||
lastPing := time.Now() // Since the agent initiated the request, assume it's alive.
|
||||
var pingMu sync.Mutex
|
||||
go pprof.Do(ctx, pprof.Labels("agent", workspaceAgent.ID.String()), func(ctx context.Context) {
|
||||
// TODO(mafredri): Is this too frequent? Use separate ping disconnect timeout?
|
||||
|
Reference in New Issue
Block a user