mirror of
https://github.com/lemonade-sdk/lemonade.git
synced 2026-11-22 19:49:40 -10:00
fix(lemond.service): let rootless Podman keep its runtime state in the host's /tmp
Every model load failed under lemond.service on Ubuntu 26.04 and Debian 13: Error: setting up Pasta: pasta failed with exit code 1: Couldn't open PID file /run/lemonade/containers/networks/rootless-netns/rootless-netns-conn.pid: Permission denied Podman 5 sets up rootless networking with pasta, under $XDG_RUNTIME_DIR, which the unit set to /run/lemonade. The AppArmor profile Ubuntu and Debian ship for pasta allows writes only under /tmp, /run/user/<uid> and home directories under /home, so it denied the PID file. ProtectHome=yes hides /run/user, and the account has no login session to create /run/user/<uid> in any case. With XDG_RUNTIME_DIR unset, Podman uses its own fallback in /tmp (/tmp/storage-run-<uid>, or /tmp/containers-user-<uid> on Podman 4), which the profile allows and Podman's own tmpfiles.d exempts from age-based cleanup. lemond's own runtime directory stays /run/lemonade, through RuntimeDirectory=. PrivateTmp goes with it. In a private /tmp, `podman` run as lemonade from a shell finds no runtime state, and Podman 5 then refreshes the shared database: the running container drops out of lemond's view, `podman stop` reports no such container, and the engine keeps holding the GPU until the service stops. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
1 parent
602fbe2e83
commit
04919f6978
2 files changed
+6
-6
No files matched your search
@@ -15,8 +15,6 @@ CacheDirectoryMode=0755
|
||||
# RuntimeDirectory for ephemeral state (PID files, Unix sockets)
|
||||
RuntimeDirectory=lemonade
|
||||
RuntimeDirectoryMode=0700
|
||||
# Rootless Podman keeps its runtime state here, since the service has no login session.
|
||||
Environment=XDG_RUNTIME_DIR=%t/lemonade
|
||||
WorkingDirectory=%S/lemonade
|
||||
# Server settings (port, host, models_dir, …) live in config.json, not env vars.
|
||||
# The few env vars lemond still reads (HF_TOKEN, LEMONADE_API_KEY,
|
||||
@@ -32,8 +30,10 @@ AmbientCapabilities=CAP_SYS_RESOURCE
|
||||
|
||||
# Security hardening. Rootless Podman creates user namespaces and runs the
|
||||
# setuid newuidmap/newgidmap helpers, so NoNewPrivileges and RestrictNamespaces
|
||||
# stay off.
|
||||
PrivateTmp=yes
|
||||
# stay off. With no login session, it keeps its runtime state in /tmp, which
|
||||
# must be the host's: that is where pasta's AppArmor profile lets it write, and
|
||||
# where `podman` run as lemonade outside the service finds the same state, so
|
||||
# PrivateTmp stays off too.
|
||||
ProtectSystem=full
|
||||
ProtectHome=yes
|
||||
RestrictRealtime=yes
|
||||
|
||||
@@ -367,8 +367,8 @@ When the container tool is Docker, the checks are:
|
||||
|
||||
`lemond` runs `podman` as a child process, the same way it runs every native backend. The unit is configured to give rootless Podman what it needs:
|
||||
|
||||
- It lets `lemond` create user namespaces and run the setuid `newuidmap`/`newgidmap` helpers that rootless Podman relies on, by running without `NoNewPrivileges` and `RestrictNamespaces`. The unit keeps `LockPersonality`, `RestrictRealtime`, `ProtectSystem`, `ProtectHome` and `PrivateTmp`: systemd applies them while it still runs as root, before it switches to the `lemonade` account, so they leave the no-new-privileges flag unset and the account's user namespace unchanged.
|
||||
- It points `XDG_RUNTIME_DIR` at the unit's existing `RuntimeDirectory` (`Environment=XDG_RUNTIME_DIR=%t/lemonade`), giving Podman a runtime directory without a login session.
|
||||
- It lets `lemond` create user namespaces and run the setuid `newuidmap`/`newgidmap` helpers that rootless Podman relies on, by running without `NoNewPrivileges` and `RestrictNamespaces`. The unit keeps `LockPersonality`, `RestrictRealtime`, `ProtectSystem` and `ProtectHome`: systemd applies them while it still runs as root, before it switches to the `lemonade` account, so they leave the no-new-privileges flag unset and the account's user namespace unchanged.
|
||||
- It leaves `XDG_RUNTIME_DIR` unset and runs without `PrivateTmp`, so Podman keeps its runtime state in the host's `/tmp` (`/tmp/storage-run-<uid>`, or `/tmp/containers-user-<uid>` before Podman 5), where Podman's own `tmpfiles.d` exempts it from age-based cleanup. The AppArmor profile that Ubuntu and Debian give `pasta` lets it write only under `/tmp`, `/run/user/<uid>` and home directories under `/home`, and `ProtectHome` hides `/run/user`. The host's `/tmp` also means `podman` run as `lemonade` outside the service finds the same runtime state: in a private `/tmp` it finds none, and Podman 5 then resets the state of containers `lemond` is running.
|
||||
|
||||
Rootless Podman also needs the `lemonade` account to own a subordinate UID/GID range: a block of host IDs that the container's own users map onto. `useradd` allocates one only for regular accounts, and the packages create `lemonade` as a system account (`useradd -r`), so each package's install script allocates the range right after its `useradd`:
|
||||
|
||||
|
||||
Reference in new issue
Block a user