func makePodToVerifyCgroupSize(cgroupNames []string, expectedCPU string, expectedMemory string) *v1.Pod {
	// convert the names to their literal cgroupfs forms...
	cgroupFsNames := []string{}
	rootCgroupName := cm.NewCgroupName(cm.RootCgroupName, defaultNodeAllocatableCgroup)
	for _, baseName := range cgroupNames {
		// Add top level cgroup used to enforce node allocatable.
		cgroupComponents := strings.Split(baseName, "/")
		cgroupName := cm.NewCgroupName(rootCgroupName, cgroupComponents...)
		cgroupFsNames = append(cgroupFsNames, toCgroupFsName(cgroupName))
	}
	framework.Logf("expecting %v cgroups to be found", cgroupFsNames)

	// build the pod command to verify cgroup sizing
	command := ""
	for _, cgroupFsName := range cgroupFsNames {
		memLimitCgroup := filepath.Join("/host_cgroups/memory", cgroupFsName, "memory.limit_in_bytes")
		cpuQuotaCgroup := filepath.Join("/host_cgroups/cpu", cgroupFsName, "cpu.cfs_quota_us")
		localCommand := "if [ ! $(cat " + memLimitCgroup + ") == " + expectedMemory + " ] || [ ! $(cat " + cpuQuotaCgroup + ") == " + expectedCPU + " ]; then exit 1; fi; "

		framework.Logf("command: %v: ", localCommand)
		command += localCommand
	}

	pod := &v1.Pod{
		ObjectMeta: metav1.ObjectMeta{
			GenerateName: "cgroup-verification-pod-",
		},
		Spec: v1.PodSpec{
			RestartPolicy: v1.RestartPolicyNever,
			Containers: []v1.Container{
				{
					Image:   busyboxImage,
					Name:    "container",
					Command: []string{"sh", "-c", command},
					VolumeMounts: []v1.VolumeMount{
						{
							Name:      "sysfscgroup",
							MountPath: "/host_cgroups",
						},
					},
				},
			},
			Volumes: []v1.Volume{
				{
					Name: "sysfscgroup",
					VolumeSource: v1.VolumeSource{
						HostPath: &v1.HostPathVolumeSource{Path: "/sys/fs/cgroup"},
					},
				},
			},
		},
	}
	return pod
}
// makePodToVerifyCgroups returns a pod that verifies the existence of the specified cgroups.
makePodToVerifyCgroups returns a pod that verifies the existence of the specified cgroups.
// makePodToVerifyCgroups returns a pod that verifies the existence of the specified cgroups .
func makePodToVerifyCgroupSize(cgroupNames []string, expectedCPU string, expectedMemory string) *v1.Pod {
	cgroupFsNames := []string{}
	rootCgroupName := cm.NewCgroupName(cm.RootCgroupName, defaultNodeAllocatableCgroup)
	for _, baseName := range cgroupNames {
		cgroupComponents := strings.Split(baseName, "/")
		cgroupName := cm.NewCgroupName(rootCgroupName, cgroupComponents...)
		cgroupFsNames = append(cgroupFsNames, toCgroupFsName(cgroupName))
	}
	framework.Logf("expecting %v cgroups to be found", cgroupFsNames)
	command := ""
	for _, cgroupFsName := range cgroupFsNames {
		memLimitCgroup := filepath.Join("/host_cgroups/memory", cgroupFsName, "memory.limit_in_bytes")
		cpuQuotaCgroup := filepath.Join("/host_cgroups/cpu", cgroupFsName, "cpu.cfs_quota_us")
		localCommand := "if [ ! $(cat " + memLimitCgroup + ") == " + expectedMemory + " ] || [ ! $(cat " + cpuQuotaCgroup + ") == " + expectedCPU + " ]; then exit 1; fi; "
		framework.Logf("command: %v: ", localCommand)
		command += localCommand
	}
	pod := &v1.Pod{
		ObjectMeta: metav1.ObjectMeta{
			GenerateName: "cgroup-verification-pod-",
		},
		Spec: v1.PodSpec{
			RestartPolicy: v1.RestartPolicyNever,
			Containers: []v1.Container{
				{
					Image:   busyboxImage,
					Name:    "container",
					Command: []string{"sh", "-c", command},
					VolumeMounts: []v1.VolumeMount{
						{
							Name:      "sysfscgroup",
							MountPath: "/host_cgroups",
						},
					},
				},
			},
			Volumes: []v1.Volume{
				{
					Name: "sysfscgroup",
					VolumeSource: v1.VolumeSource{
						HostPath: &v1.HostPathVolumeSource{Path: "/sys/fs/cgroup"},
					},
				},
			},
		},
	}
	return pod
}
func makePodToVerifyCgroupSize ( cgroupNames [ ] string , expectedCPU string , expectedMemory string ) * v1 . Pod { cgroupFsNames := [ ] string { } rootCgroupName := cm . NewCgroupName ( cm . RootCgroupName , defaultNodeAllocatableCgroup ) for _ , baseName := range cgroupNames { cgroupComponents := strings . Split ( baseName , " " ) cgroupName := cm . NewCgroupName ( rootCgroupName , cgroupComponents ... ) cgroupFsNames = append ( cgroupFsNames , toCgroupFsName ( cgroupName ) ) } framework . Logf ( " " , cgroupFsNames ) command := " " for _ , cgroupFsName := range cgroupFsNames { memLimitCgroup := filepath . Join ( " " , cgroupFsName , " " ) cpuQuotaCgroup := filepath . Join ( " " , cgroupFsName , " " ) localCommand := " " + memLimitCgroup + " " + expectedMemory + " " + cpuQuotaCgroup + " " + expectedCPU + " " framework . Logf ( " " , localCommand ) command += localCommand } pod := & v1 . Pod { ObjectMeta : metav1 . ObjectMeta { GenerateName : " " , } , Spec : v1 . PodSpec { RestartPolicy : v1 . RestartPolicyNever , Containers : [ ] v1 . Container { { Image : busyboxImage , Name : " " , Command : [ ] string { " " , " " , command } , VolumeMounts : [ ] v1 . VolumeMount { { Name : " " , MountPath : " " , } , } , } , } , Volumes : [ ] v1 . Volume { { Name : " " , VolumeSource : v1 . VolumeSource { HostPath : & v1 . HostPathVolumeSource { Path : " " } , } , } , } , } , } return pod }
makePodToVerifyCgroups returns a pod that verifies the existence of the specified cgroups.
makePodToVerifyCgroups returns a pod that verifies the existence of the specified cgroups .
// convert the names to their literal cgroupfs forms... // Add top level cgroup used to enforce node allocatable. // build the pod command to verify cgroup sizing