When working on cgroup v2 support in snapd, I attempted to run LXD 3.15 from a snap. Got this weird error when the daemon is starting:
==> Escaping the systemd cgroups
write(1, "==> Escaping the systemd cgroups"..., 33) = 33
open("/sys/fs/cgroup", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 3
fstat(3, {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
getdents(3, /* 17 entries */, 32768) = 624
getdents(3, /* 0 entries */, 32768) = 0
close(3) = 0
stat("/sys/fs/cgroup/cgroup.controllers/cgroup.procs", 0x7fff646af530) = -1 ENOTDIR (Not a directory)
stat("/sys/fs/cgroup/cgroup.max.depth/cgroup.procs", 0x7fff646af530) = -1 ENOTDIR (Not a directory)
stat("/sys/fs/cgroup/cgroup.max.descendants/cgroup.procs", 0x7fff646af530) = -1 ENOTDIR (Not a directory)
stat("/sys/fs/cgroup/cgroup.procs/cgroup.procs", 0x7fff646af530) = -1 ENOTDIR (Not a directory)
stat("/sys/fs/cgroup/cgroup.stat/cgroup.procs", 0x7fff646af530) = -1 ENOTDIR (Not a directory)
stat("/sys/fs/cgroup/cgroup.subtree_control/cgroup.procs", 0x7fff646af530) = -1 ENOTDIR (Not a directory)
stat("/sys/fs/cgroup/cgroup.threads/cgroup.procs", 0x7fff646af530) = -1 ENOTDIR (Not a directory)
stat("/sys/fs/cgroup/cpu.pressure/cgroup.procs", 0x7fff646af530) = -1 ENOTDIR (Not a directory)
stat("/sys/fs/cgroup/cpuset.cpus.effective/cgroup.procs", 0x7fff646af530) = -1 ENOTDIR (Not a directory)
stat("/sys/fs/cgroup/cpuset.mems.effective/cgroup.procs", 0x7fff646af530) = -1 ENOTDIR (Not a directory)
stat("/sys/fs/cgroup/init.scope/cgroup.procs", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
open("/sys/fs/cgroup/init.scope/cgroup.procs", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
fcntl(1, F_DUPFD, 10) = 11
close(1) = 0
fcntl(11, F_SETFD, FD_CLOEXEC) = 0
dup2(3, 1) = 1
close(3) = 0
write(1, "25418\n", 6) = 6
dup2(11, 1) = 1
close(11) = 0
stat("/sys/fs/cgroup/io.pressure/cgroup.procs", 0x7fff646af530) = -1 ENOTDIR (Not a directory)
stat("/sys/fs/cgroup/memory.pressure/cgroup.procs", 0x7fff646af530) = -1 ENOTDIR (Not a directory)
stat("/sys/fs/cgroup/system.slice/cgroup.procs", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
open("/sys/fs/cgroup/system.slice/cgroup.procs", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
fcntl(1, F_DUPFD, 10) = 11
close(1) = 0
fcntl(11, F_SETFD, FD_CLOEXEC) = 0
dup2(3, 1) = 1
close(3) = 0
write(1, "25418\n", 6) = -1 EBUSY (Device or resource busy)
write(2, "sh: ", 4sh: ) = 4
write(2, "echo: I/O error", 15echo: I/O error) = 15
write(2, "\n", 1
) = 1
dup2(11, 1) = 1
close(11) = 0
exit_group(1) = ?
+++ exited with 1 +++
error: exit status 1
The host is a Fedora 31 (rawhide actually) daily compose.
qemu:fedora-31-rawhide-64 .../tests/main/selinux-lxd# uname -a
Linux localhost 5.3.0-0.rc1.git0.1.fc31.x86_64 #1 SMP Mon Jul 22 07:54:10 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
qemu:fedora-31-rawhide-64 .../tests/main/selinux-lxd# systemctl --version
systemd 242 (v242-6.git9d34e79.fc31)
+PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD +IDN2 -IDN +PCRE2 default-hierarchy=hybrid
qemu:fedora-31-rawhide-64 .../tests/main/selinux-lxd# cat /proc/cmdline
BOOT_IMAGE=(hd0,msdos1)/boot/vmlinuz-5.3.0-0.rc1.git0.1.fc31.x86_64 root=UUID=70467fce-1cae-47ca-9afc-211237e8232d ro no_timer_check net.ifnames=0 console=tty1 console=ttyS0,115200n8 systemd.unified_cgroup_hierarchy=1
I don’t know which method LXD uses for detecting cgroups v2, but the magic of /sys/fs/cgroup
inside the mount ns looks correct:
qemu:fedora-31-rawhide-64 .../tests/main/selinux-lxd# nsenter -m/run/snapd/ns/lxd.mnt
qemu:fedora-31-rawhide-64 /# stat -f -c %t /sys/fs/cgroup/
63677270
cc @stgraber