From 61713a06f07788e4cd43e652d230871b5d6ee34e Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Mon, 3 Oct 2022 15:07:42 +0000 Subject: [PATCH] fix: Always set `DisconnectedAt` if the agent isn't connected Fixes #4315. --- coderd/workspaceagents.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/coderd/workspaceagents.go b/coderd/workspaceagents.go index 180de3654e94e..0f1ffc0003260 100644 --- a/coderd/workspaceagents.go +++ b/coderd/workspaceagents.go @@ -574,6 +574,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.