mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
6e967780c9
Closes https://github.com/coder/internal/issues/369 We can't know whether a replacement (i.e. drift of terraform state leading to a resource needing to be deleted/recreated) will take place apriori; we can only detect it at `plan` time, because the provider decides whether a resource must be replaced and it cannot be inferred through static analysis of the template. **This is likely to be the most common gotcha with using prebuilds, since it requires a slight template modification to use prebuilds effectively**, so let's head this off before it's an issue for customers. Drift details will now be logged in the workspace build logs:  Plus a notification will be sent to template admins when this situation arises:  A new metric - `coderd_prebuilt_workspaces_resource_replacements_total` - will also increment each time a workspace encounters replacements. We only track _that_ a resource replacement occurred, not how many. Just one is enough to ruin a prebuild, but we can't know apriori which replacement would cause this. For example, say we have 2 replacements: a `docker_container` and a `null_resource`; we don't know which one might cause an issue (or indeed if either would), so we just track the replacement. --------- Signed-off-by: Danny Kopping <dannykopping@gmail.com>
42 lines
2.8 KiB
Plaintext
42 lines
2.8 KiB
Plaintext
{
|
||
"_version": "1.1",
|
||
"msg_id": "00000000-0000-0000-0000-000000000000",
|
||
"payload": {
|
||
"_version": "1.2",
|
||
"notification_name": "Prebuilt Workspace Resource Replaced",
|
||
"notification_template_id": "00000000-0000-0000-0000-000000000000",
|
||
"user_id": "00000000-0000-0000-0000-000000000000",
|
||
"user_email": "bobby@coder.com",
|
||
"user_name": "Bobby",
|
||
"user_username": "bobby",
|
||
"actions": [
|
||
{
|
||
"label": "View workspace build",
|
||
"url": "http://test.com/@prebuilds-claimer/my-workspace/builds/2"
|
||
},
|
||
{
|
||
"label": "View template version",
|
||
"url": "http://test.com/templates/cern/docker/versions/angry_torvalds"
|
||
}
|
||
],
|
||
"labels": {
|
||
"claimant": "prebuilds-claimer",
|
||
"org": "cern",
|
||
"preset": "particle-accelerator",
|
||
"template": "docker",
|
||
"template_version": "angry_torvalds",
|
||
"workspace": "my-workspace",
|
||
"workspace_build_num": "2"
|
||
},
|
||
"data": {
|
||
"replacements": {
|
||
"docker_container[0]": "env, hostname"
|
||
}
|
||
},
|
||
"targets": null
|
||
},
|
||
"title": "There might be a problem with a recently claimed prebuilt workspace",
|
||
"title_markdown": "There might be a problem with a recently claimed prebuilt workspace",
|
||
"body": "Workspace my-workspace was claimed from a prebuilt workspace by prebuilds-claimer.\n\nDuring the claim, Terraform destroyed and recreated the following resources\nbecause one or more immutable attributes changed:\n\ndocker_container[0] was replaced due to changes to env, hostname\n\nWhen Terraform must change an immutable attribute, it replaces the entire resource.\nIf you’re using prebuilds to speed up provisioning, unexpected replacements will slow down\nworkspace startup—even when claiming a prebuilt environment.\n\nFor tips on preventing replacements and improving claim performance, see this guide (https://coder.com/docs/admin/templates/extending-templates/prebuilt-workspaces#preventing-resource-replacement).\n\nNOTE: this prebuilt workspace used the particle-accelerator preset.",
|
||
"body_markdown": "\nWorkspace **my-workspace** was claimed from a prebuilt workspace by **prebuilds-claimer**.\n\nDuring the claim, Terraform destroyed and recreated the following resources\nbecause one or more immutable attributes changed:\n\n- _docker_container[0]_ was replaced due to changes to _env, hostname_\n\n\nWhen Terraform must change an immutable attribute, it replaces the entire resource.\nIf you’re using prebuilds to speed up provisioning, unexpected replacements will slow down\nworkspace startup—even when claiming a prebuilt environment.\n\nFor tips on preventing replacements and improving claim performance, see [this guide](https://coder.com/docs/admin/templates/extending-templates/prebuilt-workspaces#preventing-resource-replacement).\n\nNOTE: this prebuilt workspace used the **particle-accelerator** preset.\n"
|
||
} |