Skip to content

Commit f0669de

Browse files
authored
fix cgroup path prefix for different runtime while using systemd as driver. (#160)
1 parent c961e77 commit f0669de

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

pkg/runtime/runtime.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ func (m *containerRuntimeManager) getCgroupName(pod *v1.Pod, containerID string)
164164

165165
switch m.cgroupDriver {
166166
case "systemd":
167-
return fmt.Sprintf("%s/%s-%s.scope", cgroupName.ToSystemd(), m.runtimeName, containerID), nil
167+
return fmt.Sprintf("%s/%s-%s.scope", cgroupName.ToSystemd(), cgroup.SystemdPathPrefixOfRuntime(m.runtimeName), containerID), nil
168168
case "cgroupfs":
169169
return fmt.Sprintf("%s/%s", cgroupName.ToCgroupfs(), containerID), nil
170170
default:

pkg/utils/cgroup/cgroup.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import (
66
"strings"
77

88
cgroupsystemd "github.com/opencontainers/runc/libcontainer/cgroups/systemd"
9+
10+
"k8s.io/klog"
911
)
1012

1113
// CgroupName is the abstract name of a cgroup prior to any driver specific conversion.
@@ -66,3 +68,15 @@ func escapeSystemdCgroupName(part string) string {
6668
func (cgroupName CgroupName) ToCgroupfs() string {
6769
return "/" + path.Join(cgroupName...)
6870
}
71+
72+
func SystemdPathPrefixOfRuntime(runtimeName string) string {
73+
switch runtimeName {
74+
case "cri-o":
75+
return "crio"
76+
case "containerd":
77+
return "cri-containerd"
78+
default:
79+
klog.Infof("prefix of container runtime %s was not tested. Maybe not correct!", runtimeName)
80+
return runtimeName
81+
}
82+
}

0 commit comments

Comments
 (0)