Add systemd cgroup support.

Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
Lantao Liu
2017-09-26 06:44:30 +00:00
parent 86ee919013
commit cd57d063c5
7 changed files with 53 additions and 8 deletions

View File

@@ -20,6 +20,7 @@ import (
"encoding/json"
"fmt"
"os"
"path"
"path/filepath"
"strconv"
"strings"
@@ -134,8 +135,13 @@ func makeContainerName(c *runtime.ContainerMetadata, s *runtime.PodSandboxMetada
}
// getCgroupsPath generates container cgroups path.
func getCgroupsPath(cgroupsParent string, id string) string {
// TODO(random-liu): [P0] Handle systemd.
func getCgroupsPath(cgroupsParent, id string, systemdCgroup bool) string {
if systemdCgroup {
// Convert a.slice/b.slice/c.slice to c.slice.
p := path.Base(cgroupsParent)
// runc systemd cgroup path format is "slice:prefix:name".
return strings.Join([]string{p, "cri-containerd", id}, ":")
}
return filepath.Join(cgroupsParent, id)
}