From 6159413bc9dfe2dc2d7598dedb36df45e5b40747 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Wed, 17 Mar 2021 09:24:56 +0100 Subject: [PATCH] cgroups: ignore unused controllers Someone might have created a name= controller after the container has started and so the container doesn't make use of this controller. Link: https://github.com/lxc/lxd/issues/8577 Signed-off-by: Christian Brauner --- src/lxc/cgroups/cgfsng.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c index 46ed69714..f66790a4d 100644 --- a/src/lxc/cgroups/cgfsng.c +++ b/src/lxc/cgroups/cgfsng.c @@ -2363,9 +2363,17 @@ __cgfsng_ops static bool cgfsng_attach(struct cgroup_ops *ops, } path = lxc_cmd_get_cgroup_path(name, lxcpath, h->controllers[0]); - /* not running */ - if (!path) - return false; + if (!path) { + /* + * Someone might have created a name= + * controller after the container has started and so + * the container doesn't make use of this controller. + * + * Link: https://github.com/lxc/lxd/issues/8577 + */ + TRACE("Skipping unused %s controller", maybe_empty(h->controllers[0])); + continue; + } fullpath = build_full_cgpath_from_monitorpath(h, path, "cgroup.procs"); ret = lxc_write_to_file(fullpath, pidstr, len, false, 0666); -- 2.47.2