Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automated cherry pick of #120948: Fixing attempt to deploy past allocatable memory limits test #121654

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 7 additions & 3 deletions test/e2e/windows/memory_limits.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,12 @@ func overrideAllocatableMemoryTest(f *framework.Framework, allocatablePods int)
})
framework.ExpectNoError(err)

framework.Logf("Scheduling 1 pod per node to consume all allocatable memory")
for _, node := range nodeList.Items {
status := node.Status
podMemLimt := resource.NewQuantity(status.Allocatable.Memory().Value()-(1024*1024*100), resource.BinarySI)
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{
ObjectMeta: metav1.ObjectMeta{
Name: podName,
Expand All @@ -122,7 +125,7 @@ func overrideAllocatableMemoryTest(f *framework.Framework, allocatablePods int)
Image: imageutils.GetPauseImageName(),
Resources: v1.ResourceRequirements{
Limits: v1.ResourceList{
v1.ResourceMemory: status.Allocatable[v1.ResourceMemory],
v1.ResourceMemory: *podMemLimt,
},
},
},
Expand All @@ -136,6 +139,7 @@ func overrideAllocatableMemoryTest(f *framework.Framework, allocatablePods int)
_, err = f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(context.TODO(), pod, metav1.CreateOptions{})
framework.ExpectNoError(err)
}
framework.Logf("Schedule additional pod which should not get scheduled")
podName := "mem-failure-pod"
failurePod := &v1.Pod{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -158,6 +162,7 @@ func overrideAllocatableMemoryTest(f *framework.Framework, allocatablePods int)
},
},
}
framework.Logf("Ensuring that pod %s fails to schedule", podName)
failurePod, err = f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(context.TODO(), failurePod, metav1.CreateOptions{})
framework.ExpectNoError(err)
gomega.Eventually(func() bool {
Expand All @@ -171,8 +176,7 @@ func overrideAllocatableMemoryTest(f *framework.Framework, allocatablePods int)
}
}
return false
}, 3*time.Minute, 10*time.Second).Should(gomega.Equal(true))

}, 3*time.Minute, 10*time.Second).Should(gomega.BeTrue())
}

// getNodeMemory populates a nodeMemory struct with information from the first
Expand Down