Skip to content

Commit 09e2daf

Browse files
authored
chore(docs): add external provisioner configuration for prebuilds (#20305)
## Description Update the Prebuilds troubleshooting page to include a new section, “Preventing prebuild queue contention (recommended)”, outlining a best-practice configuration to prevent prebuild jobs from overwhelming the provisioner queue. This setup introduces a dedicated prebuild provisioner pool and has been successfully tested internally in dogfood: coder/dogfood#201 Closes: #20241
1 parent 9861931 commit 09e2daf

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

docs/admin/templates/extending-templates/prebuilt-workspaces.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,63 @@ For example, the [`ami`](https://registry.terraform.io/providers/hashicorp/aws/l
364364
has [`ForceNew`](https://github.com/hashicorp/terraform-provider-aws/blob/main/internal/service/ec2/ec2_instance.go#L75-L81) set,
365365
since the AMI cannot be changed in-place._
366366

367+
### Preventing prebuild queue contention (recommended)
368+
369+
The section [Managing prebuild provisioning queues](#managing-prebuild-provisioning-queues) covers how to recover when prebuilds have already overwhelmed the provisioner queue.
370+
This section outlines a **best-practice configuration** to prevent that situation by isolating prebuild jobs to a dedicated provisioner pool.
371+
This setup is optional and requires minor template changes.
372+
373+
Coder supports [external provisioners and provisioner tags](../../provisioners/index.md), which allows you to route jobs to provisioners with matching tags.
374+
By creating external provisioners with a special tag (e.g., `is_prebuild=true`) and updating the template to conditionally add that tag for prebuild jobs,
375+
all prebuild work is handled by the prebuild pool.
376+
This keeps other provisioners available to handle user-initiated jobs.
377+
378+
#### Setup
379+
380+
1) Create a provisioner key with a prebuild tag (e.g., `is_prebuild=true`).
381+
Provisioner keys are org-scoped and their tags are inferred automatically by provisioner daemons that use the key.
382+
See [Scoped Key](../../provisioners/index.md#scoped-key-recommended) for instructions on how to create a provisioner key.
383+
384+
2) Deploy a separate provisioner pool using that key (for example, via the [Helm coder-provisioner chart](https://github.com/coder/coder/pkgs/container/chart%2Fcoder-provisioner)).
385+
Daemons in this pool will only execute jobs that include all of the tags specified in their provisioner key.
386+
See [External provisioners](../../provisioners/index.md) for environment-specific deployment examples.
387+
388+
3) Update the template to conditionally add the prebuild tag for prebuild jobs.
389+
390+
```hcl
391+
data "coder_workspace_tags" "prebuilds" {
392+
count = data.coder_workspace_owner.me.name == "prebuilds" ? 1 : 0
393+
tags = {
394+
"is_prebuild" = "true"
395+
}
396+
}
397+
```
398+
399+
Prebuild workspaces are a special type of workspace owned by the system user `prebuilds`.
400+
The value `data.coder_workspace_owner.me.name` returns the name of the workspace owner, for prebuild workspaces, this value is `"prebuild"`.
401+
Because the condition evaluates based on the workspace owner, provisioning or deprovisioning prebuilds automatically applies the prebuild tag, whereas regular jobs (like workspace creation or template import) do not.
402+
403+
> [!NOTE]
404+
> The prebuild provisioner pool can still accept non-prebuild jobs.
405+
> To achieve a fully isolated setup, add an additional tag (`is_prebuild=false`) to your standard provisioners, ensuring a clean separation between prebuild and non-prebuild workloads.
406+
> See [Provisioner Tags](../../provisioners/index.md#provisioner-tags) for further details.
407+
408+
#### Validation
409+
410+
To confirm that prebuild jobs are correctly routed to the new provisioner pool, use the Provisioner Jobs dashboard or the [`coder provisioner jobs list`](../../../reference/cli/provisioner_jobs_list.md) CLI command to inspect job metadata and tags.
411+
Follow these steps:
412+
413+
1) Publish the new template version.
414+
415+
2) Wait for the prebuilds reconciliation loop to run.
416+
The loop frequency is controlled by the configuration value [`CODER_WORKSPACE_PREBUILDS_RECONCILIATION_INTERVAL`](../../../reference/cli/server.md#--workspace-prebuilds-reconciliation-interval).
417+
When the loop runs, it will provision prebuilds for the new template version and deprovision prebuilds for the previous version.
418+
Both provisioning and deprovisioning jobs for prebuilds should display the tag `is_prebuild=true`.
419+
420+
3) Create a new workspace from a preset.
421+
Whether the preset uses a prebuild pool or not, the resulting job should not include the `is_prebuild=true` tag.
422+
This confirms that only prebuild-related jobs are routed to the dedicated prebuild provisioner pool.
423+
367424
### Monitoring and observability
368425

369426
#### Available metrics

0 commit comments

Comments
 (0)