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

feat: add managed agent license limit checks#18937

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
deansheather wants to merge2 commits intomain
base:main
Choose a base branch
Loading
fromdean/ai-usage-enforcement-2

Conversation

deansheather
Copy link
Member

  • Adds a query for counting managed agent workspace builds between two timestamps
  • The "Actual" field in the feature entitlement for managed agents is now populated with the value read from the database
  • The wsbuilder package now validates AI agent usage against the limit when a license is installed

Most of the code is new tests and updating old ones.

Closescoder/internal#777

- Adds a query for counting managed agent workspace builds between two  timestamps- The "Actual" field in the feature entitlement for managed agents is  now populated with the value read from the database- The wsbuilder package now validates AI agent usage against the limit  when a license is installed
@deansheatherdeansheather changed the titlefeat: managed agent license limit checksfeat: add managed agent license limit checksJul 21, 2025
Copy link
Contributor

@dannykoppingdannykopping left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LGTM, couple minor points; I don't need to re-review.

@@ -279,7 +281,7 @@ func (e *Executor) runOnce(t time.Time) Stats {
}

if nextTransition != "" {
builder := wsbuilder.New(ws, nextTransition).
builder := wsbuilder.New(ws, nextTransition, *e.buildUsageChecker.Load()).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This could panic; can you add some protection for it?

func (q *querier) GetManagedAgentCount(ctx context.Context, arg database.GetManagedAgentCountParams) (int64, error) {
// Must be able to read all workspaces to check usage.
if err := q.authorizeContext(ctx, policy.ActionRead, rbac.ResourceWorkspace); err != nil {
return 0, err
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Please wrap err; could get confusing if there's an authz error on a seemingly unrelated resource.

wb.transition = 'start'::workspace_transition
AND wb.has_ai_task = true
-- Exclude failed builds since they can't use AI managed agents anyway.
AND pj.job_status NOT IN ('canceled'::provisioner_job_status, 'failed'::provisioner_job_status)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Maybe it'll be more future-proof to whitelist instead of blacklist statuses...pending,running orsucceeded are the only states you care about, right? This currently ignores other statuses likecanceling,unknown, etc.

@@ -335,7 +335,7 @@ func (api *API) postWorkspaceBuilds(rw http.ResponseWriter, r *http.Request) {
return
}

builder:=wsbuilder.New(workspace,database.WorkspaceTransition(createBuild.Transition)).
builder:=wsbuilder.New(workspace,database.WorkspaceTransition(createBuild.Transition),*api.BuildUsageChecker.Load()).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Can panic

Comment on lines +1280 to +1283
returnBuildError{http.StatusInternalServerError,"failed to check build usage",err}
}
if!resp.Permitted {
returnBuildError{http.StatusForbidden,"Build is not permitted: "+resp.Message,nil}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Nit: capitalisation consistency

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@dannykoppingdannykoppingdannykopping approved these changes

@EmyrkEmyrkAwaiting requested review from Emyrk

Assignees

@deansheatherdeansheather

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Count managed agent usage and enforce limits in wsbuilder
2 participants
@deansheather@dannykopping

[8]ページ先頭

©2009-2025 Movatter.jp