From 02b3c153f3f8ba6e17ae07ab0bf8631fb0f2fb92 Mon Sep 17 00:00:00 2001 From: dnugmanov <40948799+dnugmanov@users.noreply.github.com> Date: Tue, 18 Jul 2023 23:24:51 +0600 Subject: [PATCH] feat: setIOlimits support cgroupfs (#16) Signed-off-by: Damir Nugmanov --- pkg/device/iolimit/utils.go | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/pkg/device/iolimit/utils.go b/pkg/device/iolimit/utils.go index 04bbd68..aee0834 100644 --- a/pkg/device/iolimit/utils.go +++ b/pkg/device/iolimit/utils.go @@ -96,19 +96,26 @@ func getContainerdPodCGSuffix(podUid string) string { } func getContainerdCGPath(podUid string) (string, error) { - kubepodsCGPath := baseCgroupPath + "/kubepods.slice" + // --cgroup-driver=systemd + // see reference https://kubernetes.io/docs/tasks/administer-cluster/kubeadm/configure-cgroup-driver/ + systemdCGPath := baseCgroupPath + "/kubepods.slice" podSuffix := getContainerdPodCGSuffix(podUid) - podCGPath := kubepodsCGPath + "/kubepods-" + podSuffix + ".slice" - if helpers.DirExists(podCGPath) { - return podCGPath, nil - } - podCGPath = kubepodsCGPath + "/kubepods-besteffort.slice/kubepods-besteffort-" + podSuffix + ".slice" - if helpers.DirExists(podCGPath) { - return podCGPath, nil + systemdQosClassPrefixesPath := []string{"/kubepods-", "/kubepods-besteffort.slice/kubepods-besteffort-", "/kubepods-burstable.slice/kubepods-burstable-"} + for _, qosClassPrefix := range systemdQosClassPrefixesPath { + podCGPath := systemdCGPath + qosClassPrefix + podSuffix + ".slice" + if helpers.DirExists(podCGPath) { + return podCGPath, nil + } } - podCGPath = kubepodsCGPath + "/kubepods-burstable.slice/kubepods-burstable-" + podSuffix + ".slice" - if helpers.DirExists(podCGPath) { - return podCGPath, nil + + // --cgroup-driver=cgroupfs + cgroupFsCGPath := baseCgroupPath + "/kubepods" + cgroupFsCQosPrefixes := []string{"/pod", "/besteffort/pod", "/burstable/pod"} + for _, qosClassPrefix := range cgroupFsCQosPrefixes { + podCGPath := cgroupFsCGPath + qosClassPrefix + podUid + if helpers.DirExists(podCGPath) { + return podCGPath, nil + } } return "", errors.New("CGroup Path not found for pod with Uid: " + podUid) }