Scope: Consult when working on the daemon lifecycle, state managers snapcraft.yaml or snap hooks or anything that reads/writes the data, common, or cache directories.
Daemon lifecycle logic lives in internal/daemon.
State managers are located in internal/overlord/cmdstate, internal/overlord/healthstate, internal/overlord/hookstate,
internal/overlord/ifacestate, internal/overlord/sdkstate, internal/overlord/workshopstate.
workshopd is a socket-activated systemd notify daemon that deactivates
if the ensure cycle has run at least once, there are no active connections
for a period of time and no active changes running.
Implications of the socket activation that the daemon relies on:
workshop.binmounts are recreated for all existing workshops on every daemon start up.- All interface connections are reloaded from
state.jsonon every daemon start up (seeinternal/overlord/ifacestate/ifacemgr.go:InterfaceManager.StartUp()). - Xauthority cookie is updated on every daemon startup. That allows the daemon to have an up to date cookie after the user's logout from an X11 session with a subsequent login.
- Anything that is not written to
state.jsonor to the workshop's OR SDK's LXD configuration is lost on deactivation. E.g. the state's cache that the daemon uses for verbose logs, seeinternal/overlord/state/state.go:State.Cache().
Triggered when syscheck.CheckSystem() fails (LXD missing/incompatible/down; out of storage space).
- Blocks all non-
GETrequests with the degraded error;GETstill works. - A recovery ticker re-runs
CheckSystem()continuously and clears degraded mode automatically; it also detects LXD disappearing after startup.
Three host roots, each overridable by an env var, with snap-specific defaults:
| Role | Var | Default (non-snap) | Snap value | Refresh behavior |
|---|---|---|---|---|
| Data | WORKSHOP_DATA |
/var/lib/workshop |
$SNAP_DATA |
Per revision (tied to installed version) |
| Common | WORKSHOP_COMMON |
falls back to Data | $SNAP_COMMON/workshop |
Shared across revisions |
| Cache | WORKSHOP_CACHE |
/var/cache/workshop |
$SNAP_COMMON/workshop/cache |
Shared |
Key distinction: Data is revision-scoped ($SNAP_DATA), Common survives
snap refreshes ($SNAP_COMMON).
Security backends and interfaces are registered before ensureBackendInit runs.
- Why: if
ensureBackendInitruns first,repo.Plugreturns nil andreloadConnectionssilently skips every connection;backendReadythen latches true, so the laterStartUp()call is a no-op. - Where enforced: registration ordering in
InterfaceManager.StartUp(),internal/overlord/ifacestate/ifacemgr.go. - How it breaks: if registration is reordered or the syscheck runs too early, connections never load and no error is surfaced.