Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,12 @@ trigger:
schema:
$ref: "../../../components/schemas/_index.yaml#/APIErrors"
description: Forbidden
"429":
content:
application/json:
schema:
$ref: "../../../components/schemas/_index.yaml#/APIErrors"
description: Resource limit exceeded
summary: Create workflow run
tags:
- Workflow Runs
Expand Down
16 changes: 15 additions & 1 deletion api/v1/server/handlers/v1/workflow-runs/trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (t *V1WorkflowRunsService) V1WorkflowRunCreate(ctx echo.Context, request ge
apierrors.NewAPIErrors(e.Message()),
), nil
case codes.ResourceExhausted:
return gen.V1WorkflowRunCreate400JSONResponse(
return gen.V1WorkflowRunCreate429JSONResponse(
apierrors.NewAPIErrors(e.Message()),
), nil
}
Expand Down Expand Up @@ -118,6 +118,20 @@ func (t *V1WorkflowRunsService) V1WorkflowRunCreate(ctx echo.Context, request ge
}

if rawWorkflowRun == nil || rawWorkflowRun.WorkflowRun == nil {
// check if the tenant has hit its resource limit, which would explain why the run was not created
canCreate, trLimit, limitErr := t.config.V1.TenantLimit().CanCreate(
ctx.Request().Context(),
sqlcv1.LimitResourceTASKRUN,
tenantId,
1,
)

if limitErr == nil && !canCreate {
return gen.V1WorkflowRunCreate429JSONResponse(
apierrors.NewAPIErrors(fmt.Sprintf("tenant has reached %d%% of its task runs limit", trLimit)),
), nil
}

return nil, fmt.Errorf("rawWorkflowRun not populated, we are likely seeing high latency in creating tasks")
}

Expand Down
193 changes: 101 additions & 92 deletions api/v1/server/oas/gen/openapi.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions pkg/client/rest/gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading