Skip to content

Commit 3dbbc71

Browse files
committed
Use system context to set a disconnected agent
1 parent 7334046 commit 3dbbc71

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

coderd/workspaceagents.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"cdr.dev/slog"
2727
"github.com/coder/coder/agent"
2828
"github.com/coder/coder/coderd/database"
29+
"github.com/coder/coder/coderd/database/dbauthz"
2930
"github.com/coder/coder/coderd/gitauth"
3031
"github.com/coder/coder/coderd/httpapi"
3132
"github.com/coder/coder/coderd/httpmw"
@@ -625,7 +626,11 @@ func (api *API) workspaceAgentCoordinate(rw http.ResponseWriter, r *http.Request
625626
// inactive disconnect timeout we ensure that we don't block but
626627
// also guarantee that the agent will be considered disconnected
627628
// by normal status check.
628-
ctx, cancel := context.WithTimeout(api.ctx, api.AgentInactiveDisconnectTimeout)
629+
//
630+
// Use a system context as the agent has disconnected and that token
631+
// may no longer be valid.
632+
//nolint:gocritic
633+
ctx, cancel := context.WithTimeout(dbauthz.AsSystem(api.ctx), api.AgentInactiveDisconnectTimeout)
629634
defer cancel()
630635

631636
disconnectedAt = sql.NullTime{

0 commit comments

Comments
 (0)