Skip to content

Commit 16b2fa2

Browse files
committed
fix: use system context for managed agent count query
1 parent 9a6dd73 commit 16b2fa2

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

enterprise/coderd/coderd.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,8 @@ func (api *API) CheckBuildUsage(ctx context.Context, store database.Store, templ
961961

962962
// This check is intentionally not committed to the database. It's fine if
963963
// it's not 100% accurate or allows for minor breaches due to build races.
964-
managedAgentCount, err := store.GetManagedAgentCount(ctx, database.GetManagedAgentCountParams{
964+
// nolint:gocritic // Requires permission to read all workspaces to read managed agent count.
965+
managedAgentCount, err := store.GetManagedAgentCount(agpldbauthz.AsSystemRestricted(ctx), database.GetManagedAgentCountParams{
965966
StartTime: managedAgentLimit.UsagePeriod.Start,
966967
EndTime: managedAgentLimit.UsagePeriod.End,
967968
})

enterprise/coderd/license/license.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ func Entitlements(
9999
ReplicaCount: replicaCount,
100100
ExternalAuthCount: externalAuthCount,
101101
ManagedAgentCountFn: func(ctx context.Context, startTime time.Time, endTime time.Time) (int64, error) {
102-
return db.GetManagedAgentCount(ctx, database.GetManagedAgentCountParams{
102+
// nolint:gocritic // Requires permission to read all workspaces to read managed agent count.
103+
return db.GetManagedAgentCount(dbauthz.AsSystemRestricted(ctx), database.GetManagedAgentCountParams{
103104
StartTime: startTime,
104105
EndTime: endTime,
105106
})

0 commit comments

Comments
 (0)