lxd: alpine containers fails to start with cgroups v2
$ lxc start ncopa-edge-x86
Error: Failed to run: /usr/sbin/lxd forkstart ncopa-edge-x86 /var/lib/lxd/containers /var/log/lxd/ncopa-edge-x86/lxc.conf: exit status 1
Try `lxc info --show-log ncopa-edge-x86` for more info
$ lxc info --show-log ncopa-edge-x86
Name: ncopa-edge-x86
Status: STOPPED
Type: container
Architecture: i686
Created: 2023/09/21 10:47 CEST
Last Used: 2023/09/21 11:51 CEST
Log:
lxc ncopa-edge-x86 20230921095153.560 WARN cgfsng - ../src/lxc/cgroups/cgfsng.c:cgfsng_setup_limits:3232 - Invalid argument - Ignoring cgroup2 limits on legacy cgroup system
lxc ncopa-edge-x86 20230921095153.654 ERROR cgfsng - ../src/lxc/cgroups/cgfsng.c:cgfsng_mount:2139 - No such file or directory - Failed to create cgroup at_mnt 24()
lxc ncopa-edge-x86 20230921095153.655 ERROR conf - ../src/lxc/conf.c:lxc_mount_auto_mounts:852 - No such file or directory - Failed to mount "/sys/fs/cgroup"
lxc ncopa-edge-x86 20230921095153.655 ERROR conf - ../src/lxc/conf.c:lxc_setup:4433 - Failed to setup remaining automatic mounts
lxc ncopa-edge-x86 20230921095153.655 ERROR start - ../src/lxc/start.c:do_start:1272 - Failed to setup container "ncopa-edge-x86"
lxc ncopa-edge-x86 20230921095153.655 ERROR sync - ../src/lxc/sync.c:sync_wait:34 - An error occurred in another process (expected sequence number 4)
lxc ncopa-edge-x86 20230921095153.664 WARN network - ../src/lxc/network.c:lxc_delete_network_priv:3631 - Failed to rename interface with index 0 from "eth0" to its initial name "veth17687912"
lxc ncopa-edge-x86 20230921095153.664 ERROR lxccontainer - ../src/lxc/lxccontainer.c:wait_on_daemonized_start:878 - Received container state "ABORTING" instead of "RUNNING"
lxc ncopa-edge-x86 20230921095153.664 ERROR start - ../src/lxc/start.c:__lxc_start:2107 - Failed to spawn container "ncopa-edge-x86"
lxc ncopa-edge-x86 20230921095153.664 WARN start - ../src/lxc/start.c:lxc_abort:1036 - No such process - Failed to send SIGKILL via pidfd 20 for process 14637
lxc 20230921095158.797 ERROR af_unix - ../src/lxc/af_unix.c:lxc_abstract_unix_recv_fds_iov:218 - Connection reset by peer - Failed to receive response
lxc 20230921095158.797 ERROR commands - ../src/lxc/commands.c:lxc_cmd_rsp_recv_fds:128 - Failed to receive file descriptors for command "get_state"
This happens when you have rc_cgroup_mode="unified"
in /etc/rc.conf
.
If I manually umount /sys/fs/cgroup/systemd
it starts. I think we need to verify if we are using unified, hybrid or legacy mode before mounting it.
Gentoo does this:
# Create necessary systemd paths in order for systemd containers to work on openrc host.
# /etc/rc.conf should have following values:
# rc_cgroup_mode="hybrid"
if [ -d /sys/fs/cgroup/unified ] &&
[ ! -d /sys/fs/cgroup/systemd ]; then
install -d /sys/fs/cgroup/systemd --group lxd --owner root
mount -t cgroup -o none,name=systemd systemd /sys/fs/cgroup/systemd
fi