mirror of
https://github.com/coder/coder.git
synced 2025-07-13 21:36:50 +00:00
feat!: add ability to cancel pending workspace build (#18713)
Closes #17791 This PR adds ability to cancel workspace builds that are in "pending" status. Breaking changes: - CancelWorkspaceBuild method in codersdk now accepts an optional request parameter API: - Added `expect_status` query parameter to the cancel workspace build endpoint - This parameter ensures the job hasn't changed state before canceling - API returns `412 Precondition Failed` if the job is not in the expected status - Valid values: `running` or `pending` - Wrapped the entire cancel method in a database transaction UI: - Added confirmation dialog to the `Cancel` button, since it's a destructive operation   - Enabled cancel action for pending workspaces (`expect_status=pending` is sent if workspace is in pending status)  --------- Co-authored-by: Dean Sheather <dean@deansheather.com>
This commit is contained in:
14
docs/reference/api/builds.md
generated
14
docs/reference/api/builds.md
generated
@ -491,9 +491,17 @@ curl -X PATCH http://coder-server:8080/api/v2/workspacebuilds/{workspacebuild}/c
|
||||
|
||||
### Parameters
|
||||
|
||||
| Name | In | Type | Required | Description |
|
||||
|------------------|------|--------|----------|--------------------|
|
||||
| `workspacebuild` | path | string | true | Workspace build ID |
|
||||
| Name | In | Type | Required | Description |
|
||||
|------------------|-------|--------|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `workspacebuild` | path | string | true | Workspace build ID |
|
||||
| `expect_status` | query | string | false | Expected status of the job. If expect_status is supplied, the request will be rejected with 412 Precondition Failed if the job doesn't match the state when performing the cancellation. |
|
||||
|
||||
#### Enumerated Values
|
||||
|
||||
| Parameter | Value |
|
||||
|-----------------|-----------|
|
||||
| `expect_status` | `running` |
|
||||
| `expect_status` | `pending` |
|
||||
|
||||
### Example responses
|
||||
|
||||
|
Reference in New Issue
Block a user