[systemd-devel] unable to attach pid to service delegated directory in unified mode after restart

Felip Moll felip at schedmd.com
Fri Mar 18 08:53:57 UTC 2022


On Wed, Mar 16, 2022 at 6:29 PM Felip Moll <felip at schedmd.com> wrote:

>
> On Wed, Mar 16, 2022 at 5:53 PM Lennart Poettering <lennart at poettering.net>
> wrote:
>
>> On Mi, 16.03.22 17:30, Felip Moll (felip at schedmd.com) wrote:
>>
>> > AFAIK RemainAfterExit for services actually does cleanup the cgroup
>> tree if
>> > there are no more processes in it.
>>
>> It doesn't do that if delegation is on (iirc, if not I'd consider that
>> a bug). Same logic should apply here.
>>
>>
> I will recheck that, but I am quite sure that on some tests I did the
> cgroup was cleaned up on a delegated service after the main pid terminated.
>
>
Is that a bug then?

1. Start a service with Delegate=yes and RemainAfterExit
2. Wait for the main process to start
3. Check that the unit is still active
4. Check that the cgroup is still there <--- It is gone when no pids in it

]# systemd-run -u test -p "Delegate=yes" -p "RemainAfterExit=yes" sleep 60
Running as unit: test.service
]# systemctl status test.service
● test.service - /usr/bin/sleep 60
     Loaded: loaded (/run/systemd/transient/test.service; transient)
  Transient: yes
     Active: active (running) since Fri 2022-03-18 09:47:32 CET; 5s ago
   Main PID: 6083 (sleep)
      Tasks: 1 (limit: 14068)
     Memory: 316.0K
     CGroup: /system.slice/test.service
             └─6083 /usr/bin/sleep 60

de març 18 09:47:32 llagosti systemd[1]: Started /usr/bin/sleep 60.
]# cat /proc/6083/cgroup
12:perf_event:/
11:pids:/system.slice/test.service
10:devices:/system.slice/test.service
9:cpuset:/
8:blkio:/system.slice/test.service
7:net_cls,net_prio:/
6:memory:/system.slice/test.service
5:misc:/
4:cpu,cpuacct:/system.slice/test.service
3:hugetlb:/
2:freezer:/
1:name=systemd:/system.slice/test.service
0::/system.slice/test.service
]# ls /sys/fs/cgroup/memory/system.slice/test.service/
cgroup.clone_children  memory.kmem.failcnt             memory.kme.......
......
[root at llagosti slurm.gitlab.lipixx]# systemctl status test.service
● test.service - /usr/bin/sleep 60
     Loaded: loaded (/run/systemd/transient/test.service; transient)
  Transient: yes
     Active: active (exited) since Fri 2022-03-18 09:47:32 CET; 1min 21s ago
    Process: 6083 ExecStart=/usr/bin/sleep 60 (code=exited,
status=0/SUCCESS)
   Main PID: 6083 (code=exited, status=0/SUCCESS)

de març 18 09:47:32 llagosti systemd[1]: Started /usr/bin/sleep 60.
]# ls /sys/fs/cgroup/memory/system.slice/test.service/
ls: cannot access '/sys/fs/cgroup/memory/system.slice/test.service/': No
such file or directory
]# systemctl cat test.service
# /run/systemd/transient/test.service
# This is a transient unit file, created programmatically via the systemd
API. Do not edit.
[Unit]
Description=/usr/bin/sleep 60

[Service]
Delegate=yes
RemainAfterExit=yes
ExecStart=
ExecStart="/usr/bin/sleep" "60"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20220318/bbba8557/attachment.htm>


More information about the systemd-devel mailing list