From 3964f71fe02df5a217cf2f903bbe55b83f16c3e4 Mon Sep 17 00:00:00 2001 From: Talor Itzhak Date: Tue, 18 Jul 2023 11:31:03 +0300 Subject: [PATCH] e2e:podresources: verify count for terminal pods PodResourcesAPI reports in the List call about resources of pods in terminal phase. The internal managers reassign resources assigned to pods in terminal phase, so podresources should ignore them. Whether this behavior intended or not (the docs are not unequivocal) this e2e test demonstrates and verifies the mentioned above. Signed-off-by: Talor Itzhak --- test/e2e_node/podresources_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/e2e_node/podresources_test.go b/test/e2e_node/podresources_test.go index 3d644868027..1487d05be9a 100644 --- a/test/e2e_node/podresources_test.go +++ b/test/e2e_node/podresources_test.go @@ -702,6 +702,27 @@ var _ = SIGDescribe("POD Resources [Serial] [Feature:PodResources][NodeFeature:P podresourcesListTests(ctx, f, cli, nil) podresourcesGetAllocatableResourcesTests(ctx, cli, nil, onlineCPUs, reservedSystemCPUs) }) + ginkgo.It("should account for resources of pods in terminal phase", func(ctx context.Context) { + pd := podDesc{ + cntName: "e2e-test-cnt", + podName: "e2e-test-pod", + cpuRequest: 1000, + } + pod := makePodResourcesTestPod(pd) + pod.Spec.Containers[0].Command = []string{"sh", "-c", "/bin/true"} + pod = e2epod.NewPodClient(f).CreateSync(ctx, pod) + defer e2epod.NewPodClient(f).DeleteSync(ctx, pod.Name, metav1.DeleteOptions{}, time.Minute) + err := e2epod.WaitForPodCondition(ctx, f.ClientSet, pod.Namespace, pod.Name, "Pod Succeeded", time.Minute*2, testutils.PodSucceeded) + framework.ExpectNoError(err) + endpoint, err := util.LocalEndpoint(defaultPodResourcesPath, podresources.Socket) + framework.ExpectNoError(err) + cli, conn, err := podresources.GetV1Client(endpoint, defaultPodResourcesTimeout, defaultPodResourcesMaxSize) + framework.ExpectNoError(err) + defer conn.Close() + // although the pod moved into terminal state, PodResourcesAPI still list its cpus + expectPodResources(ctx, 1, cli, []podDesc{pd}) + + }) }) })