From 2236eb04d51d0b0d4d1a085cc7a5db72e3e4ec70 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 10 Dec 2024 13:32:22 +0100 Subject: [PATCH] cgroup2: Manager.Delete: handle both "threaded" and "domain threaded" commit 6f5001dbae8ec248caad9b86c07c869f10ec5726 added special handling for threaded cgroup types. A later contribution added detection for "domain threaded" as known type, but did not update the handling to detect this type. From the original PR; > Reading cgroup.procs seems to return ENOTSUPP when threaded, so check > the type of the cg when going to delete and read the relevant file. An alternative could be to check both variants unconditionally, and to error if either Manager.Threads or Manager.Procs is non-zero. Signed-off-by: Sebastiaan van Stijn --- cgroup2/manager.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/cgroup2/manager.go b/cgroup2/manager.go index 0305471b..18484012 100644 --- a/cgroup2/manager.go +++ b/cgroup2/manager.go @@ -472,10 +472,6 @@ func (c *Manager) fallbackKill() error { } func (c *Manager) Delete() error { - var ( - tasks []uint64 - threaded bool - ) // Kernel prevents cgroups with running process from being removed, // check the tree is empty. // @@ -485,13 +481,13 @@ func (c *Manager) Delete() error { if !os.IsNotExist(err) { return err } - } else { - threaded = cgType == Threaded } - if threaded { + var tasks []uint64 + switch cgType { + case Threaded, DomainThreaded: tasks, err = c.Threads(true) - } else { + default: tasks, err = c.Procs(true) } if err != nil {