mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix(enterprise/coderd): allow deleting external-agent workspaces (#26501)
I stumbled on this while manually testing another workspace change: if a license expires after an external-agent workspace exists, deleting that workspace is rejected because `CheckBuildUsage` enforces the external-agent entitlement for every workspace transition. I assume this is unintentional from a product POV. This PR narrows the external-agent entitlement check to start builds. Creating or rebuilding external-agent workspaces still requires the feature entitlement, but stop and delete transitions stay available as cleanup paths. That matches the managed-agent entitlement precedent (i.e. the usage billing check) in the same `CheckBuildUsage` path, where license enforcement is scoped to start transitions instead of trapping users with resources they can no longer remove.
This commit is contained in:
@@ -1113,9 +1113,9 @@ func (api *API) CheckBuildUsage(
|
||||
task *database.Task,
|
||||
transition database.WorkspaceTransition,
|
||||
) (wsbuilder.UsageCheckResponse, error) {
|
||||
// If the template version has an external agent, we need to check that the
|
||||
// license is entitled to this feature.
|
||||
if templateVersion.HasExternalAgent.Valid && templateVersion.HasExternalAgent.Bool {
|
||||
// External-agent templates require an entitlement for start builds.
|
||||
if transition == database.WorkspaceTransitionStart &&
|
||||
templateVersion.HasExternalAgent.Valid && templateVersion.HasExternalAgent.Bool {
|
||||
feature, ok := api.Entitlements.Feature(codersdk.FeatureWorkspaceExternalAgent)
|
||||
if !ok || !feature.Enabled {
|
||||
return wsbuilder.UsageCheckResponse{
|
||||
|
||||
Reference in New Issue
Block a user