-
Notifications
You must be signed in to change notification settings - Fork 948
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- 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
There was a problem hiding this 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()). |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The atomic pointer is preloaded with a value before the AGPL API gets constructed, so there's no opportunity for it to be misused or ever hold nil. We also have many other atomic pointers that get dereferenced like this, such as *api.Auditor.Load()
which is used in every auditable API endpoint.
@@ -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()). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can panic
Most of the code is new tests and updating old ones.
Closes coder/internal#777