Proxmox lifecycle
How workspaces are cloned, operated, and safely removed.
Template model
Build an immutable, stopped, unprivileged LXC template with
deploy/build-workspace-template.sh. It includes the workspace user, SSH server, language and build
tools, supported agent binaries, and required runner dependencies. Do not put repositories or
credentials in the template.
Use a non-root agent user and the fixed checkout path:
/workspace/repoRebuild templates rather than editing them in place. Linked clones use the template's ZFS base snapshot, so edits to a live template dataset do not reach new workspaces. See Proxmox setup for the first-build and rebuild commands.
Creation
For each request, the controller:
- Records the workspace and ownership token.
- Allocates a VMID and creates a linked clone in the configured pool.
- Waits for clone and start tasks, then discovers its DHCP address.
- Verifies SSH, installs runtime credentials, and bootstraps the workspace.
- Checks out the requested repository and ref, writes seed files, and starts the selected runner.
- Sends the purpose and marks the workspace ready.
Every external task ID is persisted. If a response is lost or the controller restarts, it reconciles with Proxmox before retrying.
Destruction
Deletion records the desired state first, stops the LXC, re-reads its ownership marker, then purges the container. An already-absent container is success.
Only the ownership marker authorises a delete. Pool membership, hostname, and tags help discovery but
are never enough. Do not use destroy-unreferenced-disks; it can reach beyond the verified LXC.
Reconciliation
At startup and periodically, the controller resumes unfinished operations, checks stored task IDs, and compares the workspace pool with its records. Containers with an unknown or mismatched ownership marker are reported as orphans; they are never removed automatically. This protects live work after a database restore or loss.
Common failures
| Failure | Safe response |
|---|---|
| Clone response lost | Inspect the candidate VMID and ownership marker before retrying. |
| No DHCP address | Keep the failure explicit and verify the bridge, DHCP, and configured subnet. |
| SSH or checkout failure | Retain the workspace for diagnosis, then retry or destroy it. |
| Runner did not start | Keep the LXC and retry the runner step after checking the template. |
| Duplicate destroy | Treat a Proxmox 404 as success. |
Last updated on