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

Commitdcb6de1

Browse files
committed
fix: UpdatePrebuildProvisionerJobWithCancel permissions
1 parent0224665 commitdcb6de1

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

‎coderd/database/dbauthz/dbauthz.go‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4870,9 +4870,8 @@ func (q *querier) UpdateOrganizationDeletedByID(ctx context.Context, arg databas
48704870
}
48714871

48724872
func (q*querier)UpdatePrebuildProvisionerJobWithCancel(ctx context.Context,arg database.UpdatePrebuildProvisionerJobWithCancelParams) ([]uuid.UUID,error) {
4873-
// This is a system-only operation for canceling pending prebuild-related jobs
4874-
// when a new template version is promoted.
4875-
iferr:=q.authorizeContext(ctx,policy.ActionRead,rbac.ResourceSystem);err!=nil {
4873+
// Prebuild operation for canceling pending prebuild jobs from non-active template versions
4874+
iferr:=q.authorizeContext(ctx,policy.ActionUpdate,rbac.ResourcePrebuiltWorkspace);err!=nil {
48764875
return []uuid.UUID{},err
48774876
}
48784877
returnq.db.UpdatePrebuildProvisionerJobWithCancel(ctx,arg)

‎coderd/database/dbauthz/dbauthz_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ func (s *MethodTestSuite) TestProvisionerJob() {
649649
jobIDs:= []uuid.UUID{uuid.New(),uuid.New()}
650650

651651
dbm.EXPECT().UpdatePrebuildProvisionerJobWithCancel(gomock.Any(),arg).Return(jobIDs,nil).AnyTimes()
652-
check.Args(arg).Asserts(rbac.ResourceSystem,policy.ActionRead).Returns(jobIDs)
652+
check.Args(arg).Asserts(rbac.ResourcePrebuiltWorkspace,policy.ActionUpdate).Returns(jobIDs)
653653
}))
654654
s.Run("GetProvisionerJobsByIDs",s.Mocked(func(dbm*dbmock.MockStore,faker*gofakeit.Faker,check*expects) {
655655
org:=testutil.Fake(s.T(),faker, database.Organization{})

‎enterprise/coderd/prebuilds/reconcile.go‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -647,9 +647,8 @@ func (c *StoreReconciler) executeReconciliationAction(ctx context.Context, logge
647647
// This uses a criteria-based update to ensure only jobs that are still pending
648648
// at execution time are canceled, avoiding race conditions where jobs may have
649649
// transitioned to running status between query and update.
650-
// nolint:gocritic // System operation to cancel obsolete pending prebuild jobs
651650
canceledJobs,err:=c.store.UpdatePrebuildProvisionerJobWithCancel(
652-
dbauthz.AsSystemRestricted(ctx),
651+
ctx,
653652
database.UpdatePrebuildProvisionerJobWithCancelParams{
654653
Now:c.clock.Now(),
655654
PresetID: uuid.NullUUID{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp