From 8940ea179edac67e19cbf18d366f97c2405b7198 Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Tue, 4 Oct 2022 19:28:47 -0500 Subject: [PATCH] fix: Always set `DisconnectedAt` if the agent isn't connected (#4328) Fixes #4315. --- coderd/workspaceagents.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/coderd/workspaceagents.go b/coderd/workspaceagents.go index 99adbe66f4..f63b6e3088 100644 --- a/coderd/workspaceagents.go +++ b/coderd/workspaceagents.go @@ -579,6 +579,8 @@ func convertWorkspaceAgent(derpMap *tailcfg.DERPMap, coordinator *tailnet.Coordi case database.Now().Sub(dbAgent.LastConnectedAt.Time) > agentInactiveDisconnectTimeout: // The connection died without updating the last connected. workspaceAgent.Status = codersdk.WorkspaceAgentDisconnected + // Client code needs an accurate disconnected at if the agent has been inactive. + workspaceAgent.DisconnectedAt = &dbAgent.LastConnectedAt.Time case dbAgent.LastConnectedAt.Valid: // The agent should be assumed connected if it's under inactivity timeouts // and last connected at has been properly set.