Adapt cpu pinning functests to cgroup v2
The tests will now check the CPU set file in the location defined for
cgroup v2 and fallback to v1 in case of an error.
@@ -1948,9 +1948,32 @@ var _ = Describe("[owner:@sig-compute]Configurations", func() {
Context("[Serial]with cpu pinning enabled", func() {
const (
- cpusetPath = "/sys/fs/cgroup/cpuset/cpuset.cpus"
+ cgroupV1cpusetPath = "/sys/fs/cgroup/cpuset/cpuset.cpus"
+ cgroupV2cpusetPath = "/sys/fs/cgroup/cpuset.cpus.effective"
)
+ getPodCPUSet := func(pod *kubev1.Pod) (output string, err error) {
+ output, err = tests.ExecuteCommandOnPod(
+ virtClient,
+ pod,
+ "compute",
+ []string{"cat", cgroupV2cpusetPath},
+ )
+
+ if err == nil {
+ return
+ }
+
+ output, err = tests.ExecuteCommandOnPod(
+ virtClient,
+ pod,
+ "compute",
+ []string{"cat", cgroupV1cpusetPath},
+ )
+
+ return
+ }
+
It("[test_id:1684]should set the cpumanager label to false when it's not running", func() {
By("adding a cpumanger=true label to a node")
@@ -2018,12 +2041,7 @@ var _ = Describe("[owner:@sig-compute]Configurations", func() {
tests.PanicOnError(fmt.Errorf("could not find the compute container"))
}
- output, err := tests.ExecuteCommandOnPod(
- virtClient,
- readyPod,
- "compute",
- []string{"cat", cpusetPath},
- )
+ output, err := getPodCPUSet(readyPod)
log.Log.Infof("%v", output)
Expect(err).ToNot(HaveOccurred())
output = strings.TrimSuffix(output, "\n")
@@ -2138,12 +2156,7 @@ var _ = Describe("[owner:@sig-compute]Configurations", func() {
tests.PanicOnError(fmt.Errorf("could not find the compute container"))
}
- output, err := tests.ExecuteCommandOnPod(
- virtClient,
- readyPod,
- "compute",
- []string{"cat", cpusetPath},
- )
+ output, err := getPodCPUSet(readyPod)
log.Log.Infof("%v", output)
Expect(err).ToNot(HaveOccurred())
output = strings.TrimSuffix(output, "\n")
