feat: allow users to pause prebuilt workspace reconciliation (#18700)

This PR provides two commands:
* `coder prebuilds pause`
* `coder prebuilds resume`

These allow the suspension of all prebuilds activity, intended for use
if prebuilds are misbehaving.
This commit is contained in:
Sas Swart
2025-07-02 15:05:42 +00:00
committed by GitHub
parent 4072d228c5
commit 01163ea57b
42 changed files with 1336 additions and 4 deletions
+1
View File
@@ -25,6 +25,7 @@ We track the following resources:
| OAuth2ProviderAppSecret<br><i></i> | <table><thead><tr><th>Field</th><th>Tracked</th></tr></thead><tbody> | <tr><td>app_id</td><td>false</td></tr><tr><td>created_at</td><td>false</td></tr><tr><td>display_secret</td><td>false</td></tr><tr><td>hashed_secret</td><td>false</td></tr><tr><td>id</td><td>false</td></tr><tr><td>last_used_at</td><td>false</td></tr><tr><td>secret_prefix</td><td>false</td></tr></tbody></table> |
| Organization<br><i></i> | <table><thead><tr><th>Field</th><th>Tracked</th></tr></thead><tbody> | <tr><td>created_at</td><td>false</td></tr><tr><td>deleted</td><td>true</td></tr><tr><td>description</td><td>true</td></tr><tr><td>display_name</td><td>true</td></tr><tr><td>icon</td><td>true</td></tr><tr><td>id</td><td>false</td></tr><tr><td>is_default</td><td>true</td></tr><tr><td>name</td><td>true</td></tr><tr><td>updated_at</td><td>true</td></tr></tbody></table> |
| OrganizationSyncSettings<br><i></i> | <table><thead><tr><th>Field</th><th>Tracked</th></tr></thead><tbody> | <tr><td>assign_default</td><td>true</td></tr><tr><td>field</td><td>true</td></tr><tr><td>mapping</td><td>true</td></tr></tbody></table> |
| PrebuildsSettings<br><i></i> | <table><thead><tr><th>Field</th><th>Tracked</th></tr></thead><tbody> | <tr><td>id</td><td>false</td></tr><tr><td>reconciliation_paused</td><td>true</td></tr></tbody></table> |
| RoleSyncSettings<br><i></i> | <table><thead><tr><th>Field</th><th>Tracked</th></tr></thead><tbody> | <tr><td>field</td><td>true</td></tr><tr><td>mapping</td><td>true</td></tr></tbody></table> |
| Template<br><i>write, delete</i> | <table><thead><tr><th>Field</th><th>Tracked</th></tr></thead><tbody> | <tr><td>active_version_id</td><td>true</td></tr><tr><td>activity_bump</td><td>true</td></tr><tr><td>allow_user_autostart</td><td>true</td></tr><tr><td>allow_user_autostop</td><td>true</td></tr><tr><td>allow_user_cancel_workspace_jobs</td><td>true</td></tr><tr><td>autostart_block_days_of_week</td><td>true</td></tr><tr><td>autostop_requirement_days_of_week</td><td>true</td></tr><tr><td>autostop_requirement_weeks</td><td>true</td></tr><tr><td>created_at</td><td>false</td></tr><tr><td>created_by</td><td>true</td></tr><tr><td>created_by_avatar_url</td><td>false</td></tr><tr><td>created_by_name</td><td>false</td></tr><tr><td>created_by_username</td><td>false</td></tr><tr><td>default_ttl</td><td>true</td></tr><tr><td>deleted</td><td>false</td></tr><tr><td>deprecated</td><td>true</td></tr><tr><td>description</td><td>true</td></tr><tr><td>display_name</td><td>true</td></tr><tr><td>failure_ttl</td><td>true</td></tr><tr><td>group_acl</td><td>true</td></tr><tr><td>icon</td><td>true</td></tr><tr><td>id</td><td>true</td></tr><tr><td>max_port_sharing_level</td><td>true</td></tr><tr><td>name</td><td>true</td></tr><tr><td>organization_display_name</td><td>false</td></tr><tr><td>organization_icon</td><td>false</td></tr><tr><td>organization_id</td><td>false</td></tr><tr><td>organization_name</td><td>false</td></tr><tr><td>provisioner</td><td>true</td></tr><tr><td>require_active_version</td><td>true</td></tr><tr><td>time_til_dormant</td><td>true</td></tr><tr><td>time_til_dormant_autodelete</td><td>true</td></tr><tr><td>updated_at</td><td>false</td></tr><tr><td>use_classic_parameter_flow</td><td>true</td></tr><tr><td>user_acl</td><td>true</td></tr></tbody></table> |
| TemplateVersion<br><i>create, write</i> | <table><thead><tr><th>Field</th><th>Tracked</th></tr></thead><tbody> | <tr><td>archived</td><td>true</td></tr><tr><td>created_at</td><td>false</td></tr><tr><td>created_by</td><td>true</td></tr><tr><td>created_by_avatar_url</td><td>false</td></tr><tr><td>created_by_name</td><td>false</td></tr><tr><td>created_by_username</td><td>false</td></tr><tr><td>external_auth_providers</td><td>false</td></tr><tr><td>has_ai_task</td><td>false</td></tr><tr><td>id</td><td>true</td></tr><tr><td>job_id</td><td>false</td></tr><tr><td>message</td><td>false</td></tr><tr><td>name</td><td>true</td></tr><tr><td>organization_id</td><td>false</td></tr><tr><td>readme</td><td>true</td></tr><tr><td>source_example_id</td><td>false</td></tr><tr><td>template_id</td><td>true</td></tr><tr><td>updated_at</td><td>false</td></tr></tbody></table> |
+15
View File
@@ -1395,6 +1395,21 @@
"description": "Forward ports from a workspace to the local machine. For reverse port forwarding, use \"coder ssh -R\".",
"path": "reference/cli/port-forward.md"
},
{
"title": "prebuilds",
"description": "Manage Coder prebuilds",
"path": "reference/cli/prebuilds.md"
},
{
"title": "prebuilds pause",
"description": "Pause prebuilds",
"path": "reference/cli/prebuilds_pause.md"
},
{
"title": "prebuilds resume",
"description": "Resume prebuilds",
"path": "reference/cli/prebuilds_resume.md"
},
{
"title": "provisioner",
"description": "View and manage provisioner daemons and jobs",
+79
View File
@@ -0,0 +1,79 @@
# Prebuilds
## Get prebuilds settings
### Code samples
```shell
# Example request using curl
curl -X GET http://coder-server:8080/api/v2/prebuilds/settings \
-H 'Accept: application/json' \
-H 'Coder-Session-Token: API_KEY'
```
`GET /prebuilds/settings`
### Example responses
> 200 Response
```json
{
"reconciliation_paused": true
}
```
### Responses
| Status | Meaning | Description | Schema |
|--------|---------------------------------------------------------|-------------|--------------------------------------------------------------------|
| 200 | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK | [codersdk.PrebuildsSettings](schemas.md#codersdkprebuildssettings) |
To perform this operation, you must be authenticated. [Learn more](authentication.md).
## Update prebuilds settings
### Code samples
```shell
# Example request using curl
curl -X PUT http://coder-server:8080/api/v2/prebuilds/settings \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Coder-Session-Token: API_KEY'
```
`PUT /prebuilds/settings`
> Body parameter
```json
{
"reconciliation_paused": true
}
```
### Parameters
| Name | In | Type | Required | Description |
|--------|------|--------------------------------------------------------------------|----------|----------------------------|
| `body` | body | [codersdk.PrebuildsSettings](schemas.md#codersdkprebuildssettings) | true | Prebuilds settings request |
### Example responses
> 200 Response
```json
{
"reconciliation_paused": true
}
```
### Responses
| Status | Meaning | Description | Schema |
|--------|-----------------------------------------------------------------|--------------|--------------------------------------------------------------------|
| 200 | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK | [codersdk.PrebuildsSettings](schemas.md#codersdkprebuildssettings) |
| 304 | [Not Modified](https://tools.ietf.org/html/rfc7232#section-4.1) | Not Modified | |
To perform this operation, you must be authenticated. [Learn more](authentication.md).
+15
View File
@@ -4980,6 +4980,20 @@ Git clone makes use of this by parsing the URL from: 'Username for "https://gith
| `reconciliation_backoff_lookback` | integer | false | | Reconciliation backoff lookback determines the time window to look back when calculating the number of failed prebuilds, which influences the backoff strategy. |
| `reconciliation_interval` | integer | false | | Reconciliation interval defines how often the workspace prebuilds state should be reconciled. |
## codersdk.PrebuildsSettings
```json
{
"reconciliation_paused": true
}
```
### Properties
| Name | Type | Required | Restrictions | Description |
|-------------------------|---------|----------|--------------|-------------|
| `reconciliation_paused` | boolean | false | | |
## codersdk.Preset
```json
@@ -6058,6 +6072,7 @@ Git clone makes use of this by parsing the URL from: 'Username for "https://gith
| `convert_login` |
| `health_settings` |
| `notifications_settings` |
| `prebuilds_settings` |
| `workspace_proxy` |
| `organization` |
| `oauth2_provider_app` |
+1
View File
@@ -65,6 +65,7 @@ Coder — A tool for provisioning self-hosted development environments with Terr
| [<code>features</code>](./features.md) | List Enterprise features |
| [<code>licenses</code>](./licenses.md) | Add, delete, and list licenses |
| [<code>groups</code>](./groups.md) | Manage groups |
| [<code>prebuilds</code>](./prebuilds.md) | Manage Coder prebuilds |
| [<code>provisioner</code>](./provisioner.md) | View and manage provisioner daemons and jobs |
## Options
+34
View File
@@ -0,0 +1,34 @@
<!-- DO NOT EDIT | GENERATED CONTENT -->
# prebuilds
Manage Coder prebuilds
Aliases:
* prebuild
## Usage
```console
coder prebuilds
```
## Description
```console
Administrators can use these commands to manage prebuilt workspace settings.
- Pause Coder prebuilt workspace reconciliation.:
$ coder prebuilds pause
- Resume Coder prebuilt workspace reconciliation if it has been paused.:
$ coder prebuilds resume
```
## Subcommands
| Name | Purpose |
|----------------------------------------------|------------------|
| [<code>pause</code>](./prebuilds_pause.md) | Pause prebuilds |
| [<code>resume</code>](./prebuilds_resume.md) | Resume prebuilds |
+10
View File
@@ -0,0 +1,10 @@
<!-- DO NOT EDIT | GENERATED CONTENT -->
# prebuilds pause
Pause prebuilds
## Usage
```console
coder prebuilds pause
```
+10
View File
@@ -0,0 +1,10 @@
<!-- DO NOT EDIT | GENERATED CONTENT -->
# prebuilds resume
Resume prebuilds
## Usage
```console
coder prebuilds resume
```