Skip to content

Commit

Permalink
Merge pull request #121654 from marosset/automated-cherry-pick-of-#12…
Browse files Browse the repository at this point in the history
…0948-upstream-release-1.26

Automated cherry pick of #120948: Fixing attempt to deploy past allocatable memory limits test
  • Loading branch information
k8s-ci-robot committed Nov 14, 2023
2 parents 9368111 + 55cc75a commit cd1358d
Showing 1 changed file with 7 additions and 3 deletions.
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

0 comments on commit cd1358d

Please sign in to comment.