kubelet: modify the function of getCgroupSubsystemsV2 to use libcontainer API

This commit is contained in:
Kenta Tada 2020-04-13 22:20:31 +09:00
parent b0010c2d9e
commit 89a4d4b071

View File

@ -19,11 +19,9 @@ package cm
import (
"bufio"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strconv"
"strings"
libcontainercgroups "github.com/opencontainers/runc/libcontainer/cgroups"
@ -222,13 +220,12 @@ func getCgroupSubsystemsV1() (*CgroupSubsystems, error) {
// getCgroupSubsystemsV2 returns information about the enabled cgroup v2 subsystems
func getCgroupSubsystemsV2() (*CgroupSubsystems, error) {
content, err := ioutil.ReadFile(filepath.Join(util.CgroupRoot, "cgroup.controllers"))
controllers, err := libcontainercgroups.GetAllSubsystems()
if err != nil {
return nil, err
}
mounts := []libcontainercgroups.Mount{}
controllers := strings.Fields(string(content))
mountPoints := make(map[string]string, len(controllers))
for _, controller := range controllers {
mountPoints[controller] = util.CgroupRoot