diff --git a/pkg/runtime/runtime.go b/pkg/runtime/runtime.go index 135adc8b7..19440e838 100644 --- a/pkg/runtime/runtime.go +++ b/pkg/runtime/runtime.go @@ -164,7 +164,7 @@ func (m *containerRuntimeManager) getCgroupName(pod *v1.Pod, containerID string) switch m.cgroupDriver { case "systemd": - return fmt.Sprintf("%s/%s-%s.scope", cgroupName.ToSystemd(), m.runtimeName, containerID), nil + return fmt.Sprintf("%s/%s-%s.scope", cgroupName.ToSystemd(), cgroup.SystemdPathPrefixOfRuntime(m.runtimeName), containerID), nil case "cgroupfs": return fmt.Sprintf("%s/%s", cgroupName.ToCgroupfs(), containerID), nil default: diff --git a/pkg/utils/cgroup/cgroup.go b/pkg/utils/cgroup/cgroup.go index 38ce08dc0..048a524a3 100644 --- a/pkg/utils/cgroup/cgroup.go +++ b/pkg/utils/cgroup/cgroup.go @@ -6,6 +6,8 @@ import ( "strings" cgroupsystemd "github.com/opencontainers/runc/libcontainer/cgroups/systemd" + + "k8s.io/klog" ) // CgroupName is the abstract name of a cgroup prior to any driver specific conversion. @@ -66,3 +68,15 @@ func escapeSystemdCgroupName(part string) string { func (cgroupName CgroupName) ToCgroupfs() string { return "/" + path.Join(cgroupName...) } + +func SystemdPathPrefixOfRuntime(runtimeName string) string { + switch runtimeName { + case "cri-o": + return "crio" + case "containerd": + return "cri-containerd" + default: + klog.Infof("prefix of container runtime %s was not tested. Maybe not correct!", runtimeName) + return runtimeName + } +}