Skip to content

Commit 02b3c15

Browse files
authored
feat: setIOlimits support cgroupfs (#16)
Signed-off-by: Damir Nugmanov <[email protected]>
1 parent af081b6 commit 02b3c15

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

pkg/device/iolimit/utils.go

+18-11
Original file line numberDiff line numberDiff line change
@@ -96,19 +96,26 @@ func getContainerdPodCGSuffix(podUid string) string {
9696
}
9797

9898
func getContainerdCGPath(podUid string) (string, error) {
99-
kubepodsCGPath := baseCgroupPath + "/kubepods.slice"
99+
// --cgroup-driver=systemd
100+
// see reference https://kubernetes.io/docs/tasks/administer-cluster/kubeadm/configure-cgroup-driver/
101+
systemdCGPath := baseCgroupPath + "/kubepods.slice"
100102
podSuffix := getContainerdPodCGSuffix(podUid)
101-
podCGPath := kubepodsCGPath + "/kubepods-" + podSuffix + ".slice"
102-
if helpers.DirExists(podCGPath) {
103-
return podCGPath, nil
104-
}
105-
podCGPath = kubepodsCGPath + "/kubepods-besteffort.slice/kubepods-besteffort-" + podSuffix + ".slice"
106-
if helpers.DirExists(podCGPath) {
107-
return podCGPath, nil
103+
systemdQosClassPrefixesPath := []string{"/kubepods-", "/kubepods-besteffort.slice/kubepods-besteffort-", "/kubepods-burstable.slice/kubepods-burstable-"}
104+
for _, qosClassPrefix := range systemdQosClassPrefixesPath {
105+
podCGPath := systemdCGPath + qosClassPrefix + podSuffix + ".slice"
106+
if helpers.DirExists(podCGPath) {
107+
return podCGPath, nil
108+
}
108109
}
109-
podCGPath = kubepodsCGPath + "/kubepods-burstable.slice/kubepods-burstable-" + podSuffix + ".slice"
110-
if helpers.DirExists(podCGPath) {
111-
return podCGPath, nil
110+
111+
// --cgroup-driver=cgroupfs
112+
cgroupFsCGPath := baseCgroupPath + "/kubepods"
113+
cgroupFsCQosPrefixes := []string{"/pod", "/besteffort/pod", "/burstable/pod"}
114+
for _, qosClassPrefix := range cgroupFsCQosPrefixes {
115+
podCGPath := cgroupFsCGPath + qosClassPrefix + podUid
116+
if helpers.DirExists(podCGPath) {
117+
return podCGPath, nil
118+
}
112119
}
113120
return "", errors.New("CGroup Path not found for pod with Uid: " + podUid)
114121
}

0 commit comments

Comments
 (0)