]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
cgroup: Continue unit reset if cgroup is busy
authorDonald Buczek <buczek@molgen.mpg.de>
Thu, 25 Apr 2019 07:39:41 +0000 (09:39 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 20 Jun 2019 08:16:53 +0000 (10:16 +0200)
When part of the cgroup hierarchy cannot be deleted (e.g. because there
are still processes in it), do not exit unit_prune_cgroup early, but
continue so that u->cgroup_realized is reset.

Log the known case of non-empty cgroups at debug level and other errors
at warning level.

Fixes https://github.com/systemd/systemd/issues/12386

src/core/cgroup.c

index 0c885d57440f414ede597d78bf846fa7c8384b2f..7f6a22155b8d5a3efdeb13308d8b5a2ada4816fb 100644 (file)
@@ -2384,10 +2384,13 @@ void unit_prune_cgroup(Unit *u) {
         is_root_slice = unit_has_name(u, SPECIAL_ROOT_SLICE);
 
         r = cg_trim_everywhere(u->manager->cgroup_supported, u->cgroup_path, !is_root_slice);
-        if (r < 0) {
-                log_unit_debug_errno(u, r, "Failed to destroy cgroup %s, ignoring: %m", u->cgroup_path);
-                return;
-        }
+        if (r < 0)
+                /* One reason we could have failed here is, that the cgroup still contains a process.
+                 * However, if the cgroup becomes removable at a later time, it might be removed when
+                 * the containing slice is stopped. So even if we failed now, this unit shouldn't assume
+                 * that the cgroup is still realized the next time it is started. Do not return early
+                 * on error, continue cleanup. */
+                log_unit_full(u, r == -EBUSY ? LOG_DEBUG : LOG_WARNING, r, "Failed to destroy cgroup %s, ignoring: %m", u->cgroup_path);
 
         if (is_root_slice)
                 return;