@@ -96,19 +96,26 @@ func getContainerdPodCGSuffix(podUid string) string {
96
96
}
97
97
98
98
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"
100
102
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
+ }
108
109
}
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
+ }
112
119
}
113
120
return "" , errors .New ("CGroup Path not found for pod with Uid: " + podUid )
114
121
}
0 commit comments