[lxc-users] lxc-autostart, systemd and cgroups

Carlos Alberto Lopez Perez clopez at igalia.com
Thu Jan 21 01:11:36 UTC 2016


On 20/01/16 23:57, Fajar A. Nugraha wrote:
> Yep. I don't know when it was fixed, but my test system works fine. This is
> after a reboot:
> 
> root at debian:~# lxc-ls -f
> NAME  STATE    IPV4        IPV6  GROUPS  AUTOSTART
> --------------------------------------------------
> c1    RUNNING  10.0.3.194  -     -       YES
> 
> root at debian:~# lxc-attach -n c1 -- cat /proc/self/cgroup
> 8:cpuset:/lxc/c1
> 7:cpu,cpuacct:/lxc/c1
> 6:devices:/lxc/c1
> 5:net_cls,net_prio:/lxc/c1
> 4:freezer:/lxc/c1
> 3:perf_event:/lxc/c1
> 2:blkio:/lxc/c1
> 1:name=systemd:/lxc/c1
> 

And this is where things start to get funny....


After more testing I can see that if you use "lxc-attach" you get the
right cgroups. But the process started inside the container via the
container init are not getting the right cgroups.

See the following example. Just rebooted machine:


# pstree -pa 

systemd,1
  │
  ├─ [ unrelated process .... ]
  |
  ├─lxc-autostart,670 -g onboot,
  │   └─systemd,718
  │       ├─agetty,1001 --noclear tty4 linux
  │       ├─agetty,1002 --noclear tty1 linux
  │       ├─agetty,1003 --noclear tty3 linux
  │       ├─agetty,1004 --noclear tty2 linux
  │       ├─agetty,1005 --noclear --keep-baud console 115200 38400 9600 vt102
  │       └─systemd-journal,934
  |
  ├─ [ unrelated process .... ]


# cat /proc/718/cgroup 
9:perf_event:/lxc/lxctest2
8:blkio:/
7:net_cls,net_prio:/lxc/lxctest2
6:freezer:/lxc/lxctest2
5:devices:/
4:memory:/
3:cpu,cpuacct:/
2:cpuset:/lxc/lxctest2
1:name=systemd:/system.slice/lxc.service

# lxc-attach -n lxctest2 -- cat /proc/1/cgroup
9:perf_event:/lxc/lxctest2
8:blkio:/
7:net_cls,net_prio:/lxc/lxctest2
6:freezer:/lxc/lxctest2
5:devices:/
4:memory:/
3:cpu,cpuacct:/
2:cpuset:/lxc/lxctest2
1:name=systemd:/system.slice/lxc.service

# lxc-attach -n lxctest2 -- cat /proc/self/cgroup
9:perf_event:/lxc/lxctest2
8:blkio:/lxc/lxctest2
7:net_cls,net_prio:/lxc/lxctest2
6:freezer:/lxc/lxctest2
5:devices:/lxc/lxctest2
4:memory:/lxc/lxctest2
3:cpu,cpuacct:/lxc/lxctest2
2:cpuset:/lxc/lxctest2
1:name=systemd:/user.slice/user-0.slice/session-1.scope


As you can see, it is only working for the process
that fork from the lxc-attach point, but not for the process
started by the container init.

I tried replacing systemd with sysvinit in the container. Same result

Can you reproduce this?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 883 bytes
Desc: OpenPGP digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-users/attachments/20160121/143fe7ac/attachment.sig>


More information about the lxc-users mailing list