<div dir="ltr"><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Mar 16, 2022 at 6:29 PM Felip Moll <<a href="mailto:felip@schedmd.com">felip@schedmd.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Mar 16, 2022 at 5:53 PM Lennart Poettering <<a href="mailto:lennart@poettering.net" target="_blank">lennart@poettering.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Mi, 16.03.22 17:30, Felip Moll (<a href="mailto:felip@schedmd.com" target="_blank">felip@schedmd.com</a>) wrote:<br>
<br>
> AFAIK RemainAfterExit for services actually does cleanup the cgroup tree if<br>
> there are no more processes in it.<br>
<br>
It doesn't do that if delegation is on (iirc, if not I'd consider that<br>
a bug). Same logic should apply here.<br>
<br></blockquote><div><br></div><div>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.<br></div><br></div></div></blockquote><div><br></div><div>Is that a bug then?</div><div><br></div><div>1. Start a service with Delegate=yes and RemainAfterExit</div><div>2. Wait for the main process to start</div><div>3. Check that the unit is still active</div><div>4. Check that the cgroup is still there <--- It is gone when no pids in it</div><div><br></div><div>]# systemd-run -u test -p "Delegate=yes" -p "RemainAfterExit=yes" sleep 60<br>Running as unit: test.service<br>]# systemctl status test.service<br>● test.service - /usr/bin/sleep 60<br> Loaded: loaded (/run/systemd/transient/test.service; transient)<br> Transient: yes<br> Active: active (running) since Fri 2022-03-18 09:47:32 CET; 5s ago<br> Main PID: 6083 (sleep)<br> Tasks: 1 (limit: 14068)<br> Memory: 316.0K<br> CGroup: /system.slice/test.service<br> └─6083 /usr/bin/sleep 60<br><br>de març 18 09:47:32 llagosti systemd[1]: Started /usr/bin/sleep 60.<br>]# cat /proc/6083/cgroup <br>12:perf_event:/<br>11:pids:/system.slice/test.service<br>10:devices:/system.slice/test.service<br>9:cpuset:/<br>8:blkio:/system.slice/test.service<br>7:net_cls,net_prio:/<br>6:memory:/system.slice/test.service<br>5:misc:/<br>4:cpu,cpuacct:/system.slice/test.service<br>3:hugetlb:/<br>2:freezer:/<br>1:name=systemd:/system.slice/test.service<br>0::/system.slice/test.service<br>]# ls /sys/fs/cgroup/memory/system.slice/test.service/<br>cgroup.clone_children memory.kmem.failcnt memory.kme.......</div><div>......<br>[root@llagosti slurm.gitlab.lipixx]# systemctl status test.service<br>● test.service - /usr/bin/sleep 60<br> Loaded: loaded (/run/systemd/transient/test.service; transient)<br> Transient: yes<br> Active: active (exited) since Fri 2022-03-18 09:47:32 CET; 1min 21s ago<br> Process: 6083 ExecStart=/usr/bin/sleep 60 (code=exited, status=0/SUCCESS)<br> Main PID: 6083 (code=exited, status=0/SUCCESS)<br><br>de març 18 09:47:32 llagosti systemd[1]: Started /usr/bin/sleep 60.<br>]# ls /sys/fs/cgroup/memory/system.slice/test.service/<br>ls: cannot access '/sys/fs/cgroup/memory/system.slice/test.service/': No such file or directory<br>]# systemctl cat test.service<br># /run/systemd/transient/test.service<br># This is a transient unit file, created programmatically via the systemd API. Do not edit.<br>[Unit]<br>Description=/usr/bin/sleep 60<br><br>[Service]<br>Delegate=yes<br>RemainAfterExit=yes<br>ExecStart=<br>ExecStart="/usr/bin/sleep" "60"<br><br></div><div><br></div><div><br></div><div> </div></div></div>