Fixing attempt to deploy past allocatable memory limits test on Windows

Signed-off-by: Mark Rossetti <marosset@microsoft.com>
This commit is contained in:
Mark Rossetti 2023-09-29 13:26:51 -07:00
parent ef838ca27c
commit 0b76e7b69f
No known key found for this signature in database
GPG Key ID: 3188D8FC849D8762

View File

@ -105,9 +105,12 @@ func overrideAllocatableMemoryTest(ctx context.Context, f *framework.Framework,
}) })
framework.ExpectNoError(err) framework.ExpectNoError(err)
framework.Logf("Scheduling 1 pod per node to consume all allocatable memory")
for _, node := range nodeList.Items { for _, node := range nodeList.Items {
status := node.Status status := node.Status
podMemLimt := resource.NewQuantity(status.Allocatable.Memory().Value()-(1024*1024*100), resource.BinarySI)
podName := "mem-test-" + string(uuid.NewUUID()) podName := "mem-test-" + string(uuid.NewUUID())
framework.Logf("Scheduling pod %s on node %s (allocatable memory=%v) with memory limit %v", podName, node.Name, status.Allocatable.Memory(), podMemLimt)
pod := &v1.Pod{ pod := &v1.Pod{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: podName, Name: podName,
@ -119,7 +122,7 @@ func overrideAllocatableMemoryTest(ctx context.Context, f *framework.Framework,
Image: imageutils.GetPauseImageName(), Image: imageutils.GetPauseImageName(),
Resources: v1.ResourceRequirements{ Resources: v1.ResourceRequirements{
Limits: v1.ResourceList{ Limits: v1.ResourceList{
v1.ResourceMemory: status.Allocatable[v1.ResourceMemory], v1.ResourceMemory: *podMemLimt,
}, },
}, },
}, },
@ -133,6 +136,7 @@ func overrideAllocatableMemoryTest(ctx context.Context, f *framework.Framework,
_, err = f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(ctx, pod, metav1.CreateOptions{}) _, err = f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(ctx, pod, metav1.CreateOptions{})
framework.ExpectNoError(err) framework.ExpectNoError(err)
} }
framework.Logf("Schedule additional pod which should not get scheduled")
podName := "mem-failure-pod" podName := "mem-failure-pod"
failurePod := &v1.Pod{ failurePod := &v1.Pod{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
@ -155,6 +159,7 @@ func overrideAllocatableMemoryTest(ctx context.Context, f *framework.Framework,
}, },
}, },
} }
framework.Logf("Ensuring that pod %s fails to schedule", podName)
failurePod, err = f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(ctx, failurePod, metav1.CreateOptions{}) failurePod, err = f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(ctx, failurePod, metav1.CreateOptions{})
framework.ExpectNoError(err) framework.ExpectNoError(err)
gomega.Eventually(ctx, func() bool { gomega.Eventually(ctx, func() bool {
@ -169,7 +174,6 @@ func overrideAllocatableMemoryTest(ctx context.Context, f *framework.Framework,
} }
return false return false
}, 3*time.Minute, 10*time.Second).Should(gomega.BeTrue()) }, 3*time.Minute, 10*time.Second).Should(gomega.BeTrue())
} }
// getNodeMemory populates a nodeMemory struct with information from the first // getNodeMemory populates a nodeMemory struct with information from the first