Skip to content

Commit 875274d

Browse files
stirbymatifali
authored andcommitted
rough draft of workspace lifecycle
1 parent 15592cb commit 875274d

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

docs/admin/workspaces/lifecycle.md

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@ Workspaces are flexible, reproducible, and isolated units of compute. Workspaces
55

66
This page covers how workspaces move through this lifecycle. To learn about automating workspace schedules for cost control, read the [workspace scheduling docs](./schedule.md).
77

8-
## Resources and persistence
8+
## Workspace ephemerality
99

1010
In Coder, your workspaces are composed of resources which may be _ephemeral_ or _persistent_. Persistent resources stay provisioned when the workspace is stopped, where as ephemeral resources are destroyed and recreated on restart. All resources are destroyed when a workspace is deleted.
1111

12-
13-
Ephemeral resources reduce the cost of stopped workspaces and ensure reproducibility of your environments.
14-
1512
A common example of their usage is to have a workspace whose only persistent resource is the home directory. This allows the developer to retain their work while ensuring the rest of their environment is consistently up-to-date on each workspace restart.
1613

1714
The persistence of resources in your workspace is determined by Terraform in your template. Read more from the official documentation on [Terraform resource behavior](https://developer.hashicorp.com/terraform/language/resources/behavior#how-terraform-applies-a-configuration) and how to configure it using the [lifecycle argument](https://developer.hashicorp.com/terraform/language/meta-arguments/lifecycle).
1815

16+
<!-- TODO: Template resource persistence link
17+
https://coder.com/docs/templates/resource-persistence
18+
-->
19+
1920
## Workspace States
2021

2122
Generally, there are 3 states that a workspace may fall into:
@@ -41,27 +42,40 @@ When a user creates a workspace, they're sending a build request to the control
4142
The resources that run the agent are described as _computational resources_,
4243
while those that don't are called _peripheral resources_. A workspace must contain some computational resource to run the Coder agent process.
4344

44-
The provisioned workspace's computational resources start the agent process, which opens connections to your workspace via SSH, the terminal, and IDES like [JetBrains](../../user-guides/workspace-access/jetbrains.md) or [VSCode](../../user-guides/workspace-access/vscode.md).
45-
46-
Once started, the Coder agent is responsible for running your workspace startup scripts. These may configure tools, service connections, or personalization like [dotfiles](../../user-guides/workspace-dotfiles.md).
47-
45+
The provisioned workspace's computational resources start the agent process, which opens connections to your workspace via SSH, the terminal, and IDES such as [JetBrains](../../user-guides/workspace-access/jetbrains.md) or [VSCode](../../user-guides/workspace-access/vscode.md).
4846

47+
Once started, the Coder agent is responsible for running your workspace startup scripts. These may configure tools, service connections, or personalization with [dotfiles](../../user-guides/workspace-dotfiles.md).
4948

5049
Once these steps have completed, your workspace will now be in the `Running` state. You can access it via any of the [supported methods](../../user-guides/workspace-access/README.md), stop it when you're away, or delete it once it's no longer in use.
5150

5251
## Stopping workspaces
5352

5453
Workspaces may be stopped manually by users and admins in the dashboard, CLI, or API. Workspaces may be automatically stopped by scheduling configuration to reduce the uptime of costly resources.
5554

55+
Once stopped, a workspace may resume running by starting it manually, or via user connection if automatic start is enabled.
5656

57+
<!-- TODO: Add "start on connect" docs link -->
5758

5859
## Deleting workspaces
5960

61+
Similarly to stopping, workspaces may be deleted manually or automatically by Coder through workspace dormancy.
62+
63+
A delete workspace build runs `terraform destroy`, destroying both persistent and ephemeral resources. This action can not be reverted.
64+
65+
When enabled on enterprise deployments, workspaces will become dormant after a specified duration of inactivity. Then, if left dormant, the workspaces will be queued for deletion. Learn about configuraing workspace dormancy in the template scheduling docs.
66+
67+
### Orphan resources
68+
69+
Typically, when a workspace is deleted, all of the workspace's resources are deleted along with it. Rarely, one may wish to delete a workspace without deleting its resources, e.g. a workspace in a broken state. Users with the Template Admin role have the option to do so both in the UI, and also in the CLI by running the delete command with the `--orphan` flag. This option should be considered cautiously as orphaning may lead to unaccounted cloud resources.
70+
6071

61-
## Unhealthy and Failed workspaces
72+
## Broken workspace states
6273

74+
During a workspace start or stop build, one of two errors may lead to a broken state. If the call to `terraform apply` fails to correctly provision resources, a workspace build has **failed**. If the computational resources fail to connect the agent, a workspace becomes **unhealthy**.
6375

76+
A failed workspace is most often caused by misalignment from the definition in your template's Terraform file and the target resources on your infrastructure. Unhealthy workspaces are usually caused by a misconfiguration in the agent or startup scripts it runs.
6477

78+
<!-- TODO: Needs review/addition -->
6579

6680
## Next steps
6781
<!--

0 commit comments

Comments
 (0)