manager: Freeze/Thaw: Don't fail units w/o cgroup
authorAdrian Vovk <adrianvovk@gmail.com>
Fri, 29 Mar 2024 00:38:09 +0000 (20:38 -0400)
committerMike Yuan <me@yhndnzj.com>
Fri, 29 Mar 2024 18:58:53 +0000 (02:58 +0800)
Previously, it was impossible to freeze or thaw a slice if it is an
ancestor to a unit that had no running cgroup (i.e. a service with
RemainAfterExit=yes). Instead of failing with EBUSY (which would
confusingly get reported as "Unit has pending job") we just silently
no-op.

I noticed this because we now have user-runtime-dir@.service, which
would make it impossible to freeze/thaw user.slice or user-<UID>.slice

src/core/cgroup.c

index fdca434df9bfc8779c9a6ca54e8bd91f15914d86..852a16622f1108e689e014755c62de4dd44ec6a7 100644 (file)
@@ -5128,7 +5128,7 @@ int unit_cgroup_freezer_action(Unit *u, FreezerAction action) {
 
         CGroupRuntime *crt = unit_get_cgroup_runtime(u);
         if (!crt || !crt->cgroup_realized)
-                return -EBUSY;
+                return 0; /* No cgroup = nothing running to freeze */
 
         unit_next_freezer_state(u, action, &next, &target);