# Lab provisioner [Русский](README.md) | English labd is a Go service that creates and deletes LXD VMs for practical labs. Only labd receives the LXD socket; the backend uses the `api/labd/` contract with TLS and a bearer token. Membership in the `lxd` group grants root-equivalent access to the host. The built-in template registry is currently empty: lab creation returns `validation_failed`. The backend contains a port and client but does not connect them in bootstrap yet. Console token issuance is implemented; WebSocket attach returns 501. A usable workflow needs prepared images, templates, and integration. - `internal/template/` - nodes, links, variant parameters, and lab checkers. - `internal/lxd/` - LXD REST client through a Unix socket and a test fake. - `internal/pool/` - memory budget, creation, readiness, checking, and deletion. - `internal/store/`, `internal/reaper/` - JSON state, lifetimes, and orphan cleanup. - `internal/server/`, `internal/api/` - API and ogen code from `api/labd/`. A lab record is persisted before any LXD object is created. Deletion retries until every object is gone, then releases capacity. A corrupt state file blocks startup; `/readyz` requires successful reconciliation with LXD. The file contains variant seeds; keep it at mode 0600. ## Running and checking ```sh make -C labd check ``` This check uses the LXD fake. `make -C labd test-live` creates and deletes a real lab on a separate test LXD; set `LABD_LIVE_SOCKET` and `LABD_LIVE_SOURCE=instance/snapshot`. Never run it against production. On the app host, use the [systemd unit](../deploy/labs/lincodex-labd.service) and [example settings](../deploy/labs/labd.env.example). TLS, a token file, and restricted clients are required. `LABD_MEMORY_BUDGET_MIB`, `LABD_MAX_LABS`, and `LABD_MAX_LIFETIME` control capacity and lifetime; `internal/config/` reads all `LABD_*` settings. Before enabling labs, test L2 isolation, MAC/port filtering, cloud-init application, and node authentication during checks. LXD group access remains privileged regardless of systemd restrictions. Networks and host preparation: [DEPLOYMENT.md](../docs/en/DEPLOYMENT.md#labs-and-labd).