fix: ensure agent DisconnectedAt is greater than or equal LastConnectedAt (#6692)

See https://github.com/coder/coder/actions/runs/4471502401/jobs/7856475920
This commit is contained in:
Kyle Carberry
2023-03-21 11:08:39 -05:00
committed by GitHub
parent fce8a4adf0
commit 1b35ac80f2
2 changed files with 9 additions and 3 deletions

View File

@ -915,7 +915,9 @@ func convertWorkspaceAgent(derpMap *tailcfg.DERPMap, coordinator tailnet.Coordin
// to start up.
workspaceAgent.Status = codersdk.WorkspaceAgentConnecting
}
case dbAgent.DisconnectedAt.Time.After(dbAgent.LastConnectedAt.Time):
// We check before instead of after because last connected at and
// disconnected at can be equal timestamps in tight-timed tests.
case !dbAgent.DisconnectedAt.Time.Before(dbAgent.LastConnectedAt.Time):
// If we've disconnected after our last connection, we know the
// agent is no longer connected.
workspaceAgent.Status = codersdk.WorkspaceAgentDisconnected