mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 19:01:49 +00:00
verifying LimitRange update is effective before creating new pod
This commit is contained in:
parent
68d22a878d
commit
e6f32eea74
@ -18,6 +18,7 @@ package scheduling
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"reflect"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"k8s.io/api/core/v1"
|
"k8s.io/api/core/v1"
|
||||||
@ -81,6 +82,7 @@ var _ = SIGDescribe("LimitRange", func() {
|
|||||||
|
|
||||||
By("Fetching the LimitRange to ensure it has proper values")
|
By("Fetching the LimitRange to ensure it has proper values")
|
||||||
limitRange, err = f.ClientSet.CoreV1().LimitRanges(f.Namespace.Name).Get(limitRange.Name, metav1.GetOptions{})
|
limitRange, err = f.ClientSet.CoreV1().LimitRanges(f.Namespace.Name).Get(limitRange.Name, metav1.GetOptions{})
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
expected := v1.ResourceRequirements{Requests: defaultRequest, Limits: defaultLimit}
|
expected := v1.ResourceRequirements{Requests: defaultRequest, Limits: defaultLimit}
|
||||||
actual := v1.ResourceRequirements{Requests: limitRange.Spec.Limits[0].DefaultRequest, Limits: limitRange.Spec.Limits[0].Default}
|
actual := v1.ResourceRequirements{Requests: limitRange.Spec.Limits[0].DefaultRequest, Limits: limitRange.Spec.Limits[0].Default}
|
||||||
err = equalResourceRequirement(expected, actual)
|
err = equalResourceRequirement(expected, actual)
|
||||||
@ -140,6 +142,13 @@ var _ = SIGDescribe("LimitRange", func() {
|
|||||||
limitRange, err = f.ClientSet.CoreV1().LimitRanges(f.Namespace.Name).Update(limitRange)
|
limitRange, err = f.ClientSet.CoreV1().LimitRanges(f.Namespace.Name).Update(limitRange)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
|
By("Verifying LimitRange updating is effective")
|
||||||
|
Expect(wait.Poll(time.Second*2, time.Second*20, func() (bool, error) {
|
||||||
|
limitRange, err = f.ClientSet.CoreV1().LimitRanges(f.Namespace.Name).Get(limitRange.Name, metav1.GetOptions{})
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
return reflect.DeepEqual(limitRange.Spec.Limits[0].Min, newMin), nil
|
||||||
|
})).NotTo(HaveOccurred())
|
||||||
|
|
||||||
By("Creating a Pod with less than former min resources")
|
By("Creating a Pod with less than former min resources")
|
||||||
pod = f.NewTestPod(podName, getResourceList("10m", "50Mi", "50Gi"), v1.ResourceList{})
|
pod = f.NewTestPod(podName, getResourceList("10m", "50Mi", "50Gi"), v1.ResourceList{})
|
||||||
pod, err = f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(pod)
|
pod, err = f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(pod)
|
||||||
|
Loading…
Reference in New Issue
Block a user