only collect metrics for cgroups required by the summary API
This commit is contained in:
@@ -236,3 +236,37 @@ func getCgroupProcs(dir string) ([]int, error) {
|
||||
func GetPodCgroupNameSuffix(podUID types.UID) string {
|
||||
return podCgroupNamePrefix + string(podUID)
|
||||
}
|
||||
|
||||
// NodeAllocatableRoot returns the literal cgroup path for the node allocatable cgroup
|
||||
func NodeAllocatableRoot(cgroupRoot, cgroupDriver string) string {
|
||||
root := ParseCgroupfsToCgroupName(cgroupRoot)
|
||||
nodeAllocatableRoot := NewCgroupName(root, defaultNodeAllocatableCgroupName)
|
||||
if libcontainerCgroupManagerType(cgroupDriver) == libcontainerSystemd {
|
||||
return nodeAllocatableRoot.ToSystemd()
|
||||
}
|
||||
return nodeAllocatableRoot.ToCgroupfs()
|
||||
}
|
||||
|
||||
// GetKubeletContainer returns the cgroup the kubelet will use
|
||||
func GetKubeletContainer(kubeletCgroups string) (string, error) {
|
||||
if kubeletCgroups == "" {
|
||||
cont, err := getContainer(os.Getpid())
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return cont, nil
|
||||
}
|
||||
return kubeletCgroups, nil
|
||||
}
|
||||
|
||||
// GetRuntimeContainer returns the cgroup used by the container runtime
|
||||
func GetRuntimeContainer(containerRuntime, runtimeCgroups string) (string, error) {
|
||||
if containerRuntime == "docker" {
|
||||
cont, err := getContainerNameForProcess(dockerProcessName, dockerPidFile)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to get container name for docker process: %v", err)
|
||||
}
|
||||
return cont, nil
|
||||
}
|
||||
return runtimeCgroups, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user