mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
libct/cg/sd/v2: Destroy: remove cgroups recursively
Currently, we can create subcgroup in a rootless container with systemd cgroupv2 on centos8. But after the container exited, the container cgroup and its subcgroup will not be removed. Fix this by removing all directories recursively. Fixes: https://github.com/opencontainers/runc/issues/3225 Signed-off-by: Kang Chen <kongchen28@gmail.com>
This commit is contained in:
@@ -3,7 +3,6 @@ package systemd
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
"os"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -301,9 +300,10 @@ func (m *unifiedManager) Destroy() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX this is probably not needed, systemd should handle it
|
// systemd 239 do not remove sub-cgroups.
|
||||||
err := os.Remove(m.path)
|
err := m.fsMgr.Destroy()
|
||||||
if err != nil && !os.IsNotExist(err) {
|
// fsMgr.Destroy has handled ErrNotExist
|
||||||
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user