Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd22d34e

Browse files
authored
fix: pass context with authorization to agentapi (#20959)
The agentapi context needs to be a context with some amount ofauthorization attached to it via the context so that the cache refreshroutine can fetch the workspace from the db via GetWorkspaceForAgentID.---------Signed-off-by: Callum Styan <callumstyan@gmail.com>
1 parenta6a8a06 commitd22d34e

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

‎coderd/agentapi/api.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ type Options struct {
6969
WorkspaceID uuid.UUID
7070
OrganizationID uuid.UUID
7171

72-
Ctx context.Context
72+
AuthenticatedCtx context.Context
7373
Log slog.Logger
7474
Clock quartz.Clock
7575
Database database.Store
@@ -220,7 +220,7 @@ func New(opts Options, workspace database.Workspace) *API {
220220

221221
// Start background cache refresh loop to handle workspace changes
222222
// like prebuild claims where owner_id and other fields may be modified in the DB.
223-
goapi.startCacheRefreshLoop(opts.Ctx)
223+
goapi.startCacheRefreshLoop(opts.AuthenticatedCtx)
224224

225225
returnapi
226226
}

‎coderd/agentapi/metadata_test.go‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -671,15 +671,15 @@ func TestBatchUpdateMetadata(t *testing.T) {
671671

672672
// Create full API with cached workspace fields (initial state)
673673
api:=agentapi.New(agentapi.Options{
674-
Ctx:ctxWithActor,
675-
AgentID:agentID,
676-
WorkspaceID:workspaceID,
677-
OwnerID:ownerID,
678-
OrganizationID:orgID,
679-
Database:dbauthz.New(dbM,auth,testutil.Logger(t),accessControlStore),
680-
Log:testutil.Logger(t),
681-
Clock:mClock,
682-
Pubsub:pub,
674+
AuthenticatedCtx:ctxWithActor,
675+
AgentID:agentID,
676+
WorkspaceID:workspaceID,
677+
OwnerID:ownerID,
678+
OrganizationID:orgID,
679+
Database:dbauthz.New(dbM,auth,testutil.Logger(t),accessControlStore),
680+
Log:testutil.Logger(t),
681+
Clock:mClock,
682+
Pubsub:pub,
683683
},initialWorkspace)// Cache is initialized with 9am schedule and "my-workspace" name
684684

685685
// Wait for ticker to be set up and release it so it can fire

‎coderd/workspaceagentsrpc.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ func (api *API) workspaceAgentRPC(rw http.ResponseWriter, r *http.Request) {
132132
WorkspaceID:workspace.ID,
133133
OrganizationID:workspace.OrganizationID,
134134

135-
Ctx:api.ctx,
135+
AuthenticatedCtx:ctx,
136136
Log:logger,
137137
Clock:api.Clock,
138138
Database:api.Database,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp