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
Let the quota evaluator handle mutating specs of pod & pvc #51174
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -147,6 +147,85 @@ var _ = framework.KubeDescribe("ResourceQuota", func() { | |
Expect(err).NotTo(HaveOccurred()) | ||
}) | ||
|
||
It("should create a ResourceQuota and capture the life of an uninitialized pod.", func() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I leave the test here to show what the end goal is. I can move the test to #50344 if that's better. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's fine if 50344 uncomments it. |
||
// TODO: uncomment the test when #50344 is merged. | ||
// By("Creating a ResourceQuota") | ||
// quotaName := "test-quota" | ||
// resourceQuota := newTestResourceQuota(quotaName) | ||
// resourceQuota, err := createResourceQuota(f.ClientSet, f.Namespace.Name, resourceQuota) | ||
// Expect(err).NotTo(HaveOccurred()) | ||
|
||
// By("Ensuring resource quota status is calculated") | ||
// usedResources := v1.ResourceList{} | ||
// usedResources[v1.ResourceQuotas] = resource.MustParse("1") | ||
// err = waitForResourceQuota(f.ClientSet, f.Namespace.Name, quotaName, usedResources) | ||
// Expect(err).NotTo(HaveOccurred()) | ||
|
||
// By("Creating an uninitialized Pod that fits quota") | ||
// podName := "test-pod" | ||
// requests := v1.ResourceList{} | ||
// requests[v1.ResourceCPU] = resource.MustParse("500m") | ||
// requests[v1.ResourceMemory] = resource.MustParse("252Mi") | ||
// pod := newTestPodForQuota(f, podName, requests, v1.ResourceList{}) | ||
// pod.Initializers = &metav1.Initializers{Pending: []metav1.Initializer{{Name: "unhandled"}}} | ||
// _, err = f.ClientSet.Core().Pods(f.Namespace.Name).Create(pod) | ||
// // because no one is handling the initializer, server will return a 504 timeout | ||
// if err != nil && !errors.IsTimeout(err) { | ||
// framework.Failf("expect err to be timeout error, got %v", err) | ||
// } | ||
// podToUpdate, err := f.ClientSet.Core().Pods(f.Namespace.Name).Get(podName, metav1.GetOptions{}) | ||
// Expect(err).NotTo(HaveOccurred()) | ||
|
||
// By("Ensuring ResourceQuota status captures the pod usage") | ||
// usedResources[v1.ResourceQuotas] = resource.MustParse("1") | ||
// usedResources[v1.ResourcePods] = resource.MustParse("1") | ||
// usedResources[v1.ResourceCPU] = requests[v1.ResourceCPU] | ||
// usedResources[v1.ResourceMemory] = requests[v1.ResourceMemory] | ||
// err = waitForResourceQuota(f.ClientSet, f.Namespace.Name, quotaName, usedResources) | ||
// Expect(err).NotTo(HaveOccurred()) | ||
|
||
// By("Not allowing an uninitialized pod to be created that exceeds remaining quota") | ||
// requests = v1.ResourceList{} | ||
// requests[v1.ResourceCPU] = resource.MustParse("600m") | ||
// requests[v1.ResourceMemory] = resource.MustParse("100Mi") | ||
// pod = newTestPodForQuota(f, "fail-pod", requests, v1.ResourceList{}) | ||
// pod.Initializers = &metav1.Initializers{Pending: []metav1.Initializer{{Name: "unhandled"}}} | ||
// pod, err = f.ClientSet.Core().Pods(f.Namespace.Name).Create(pod) | ||
// Expect(err).To(HaveOccurred()) | ||
// fmt.Println("CHAO: err=", err) | ||
|
||
// By("Ensuring an uninitialized pod can update its resource requirements") | ||
// // a pod cannot dynamically update its resource requirements. | ||
// requests = v1.ResourceList{} | ||
// requests[v1.ResourceCPU] = resource.MustParse("100m") | ||
// requests[v1.ResourceMemory] = resource.MustParse("100Mi") | ||
// podToUpdate.Spec.Containers[0].Resources.Requests = requests | ||
// _, err = f.ClientSet.Core().Pods(f.Namespace.Name).Update(podToUpdate) | ||
// Expect(err).NotTo(HaveOccurred()) | ||
|
||
// By("Ensuring attempts to update pod resource requirements did change quota usage") | ||
// usedResources[v1.ResourceQuotas] = resource.MustParse("1") | ||
// usedResources[v1.ResourcePods] = resource.MustParse("1") | ||
// usedResources[v1.ResourceCPU] = requests[v1.ResourceCPU] | ||
// usedResources[v1.ResourceMemory] = requests[v1.ResourceMemory] | ||
// err = waitForResourceQuota(f.ClientSet, f.Namespace.Name, quotaName, usedResources) | ||
// Expect(err).NotTo(HaveOccurred()) | ||
|
||
// TODO: uncomment the test when the replenishment_controller uses the | ||
// sharedInformer that list/watches uninitialized objects. | ||
// By("Deleting the pod") | ||
// err = f.ClientSet.Core().Pods(f.Namespace.Name).Delete(podName, metav1.NewDeleteOptions(0)) | ||
// Expect(err).NotTo(HaveOccurred()) | ||
// | ||
// By("Ensuring resource quota status released the pod usage") | ||
// usedResources[v1.ResourceQuotas] = resource.MustParse("1") | ||
// usedResources[v1.ResourcePods] = resource.MustParse("0") | ||
// usedResources[v1.ResourceCPU] = resource.MustParse("0") | ||
// usedResources[v1.ResourceMemory] = resource.MustParse("0") | ||
// err = waitForResourceQuota(f.ClientSet, f.Namespace.Name, quotaName, usedResources) | ||
// Expect(err).NotTo(HaveOccurred()) | ||
}) | ||
|
||
It("should create a ResourceQuota and capture the life of a pod.", func() { | ||
By("Creating a ResourceQuota") | ||
quotaName := "test-quota" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i have a goal to enable the following:
#51370
where do you recommend i best layer in the referenced goal with the need to support initializers?