mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-11 21:12:07 +00:00
Quota ignores pod compute resources on updates
This commit is contained in:
parent
265c7df39e
commit
b92b7255f4
@ -47,7 +47,8 @@ func NewPodEvaluator(kubeClient clientset.Interface) quota.Evaluator {
|
||||
InternalGroupKind: api.Kind("Pod"),
|
||||
InternalOperationResources: map[admission.Operation][]api.ResourceName{
|
||||
admission.Create: allResources,
|
||||
admission.Update: computeResources,
|
||||
// TODO: the quota system can only charge for deltas on compute resources when pods support updates.
|
||||
// admission.Update: computeResources,
|
||||
},
|
||||
GetFuncByNamespace: func(namespace, name string) (runtime.Object, error) {
|
||||
return kubeClient.Core().Pods(namespace).Get(name)
|
||||
|
@ -241,6 +241,7 @@ var _ = framework.KubeDescribe("ResourceQuota", func() {
|
||||
pod := newTestPodForQuota(podName, requests, api.ResourceList{})
|
||||
pod, err = f.Client.Pods(f.Namespace.Name).Create(pod)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
podToUpdate := pod
|
||||
|
||||
By("Ensuring ResourceQuota status captures the pod usage")
|
||||
usedResources[api.ResourceQuotas] = resource.MustParse("1")
|
||||
@ -258,6 +259,19 @@ var _ = framework.KubeDescribe("ResourceQuota", func() {
|
||||
pod, err = f.Client.Pods(f.Namespace.Name).Create(pod)
|
||||
Expect(err).To(HaveOccurred())
|
||||
|
||||
By("Ensuring a pod cannot update its resource requirements")
|
||||
// a pod cannot dynamically update its resource requirements.
|
||||
requests = api.ResourceList{}
|
||||
requests[api.ResourceCPU] = resource.MustParse("100m")
|
||||
requests[api.ResourceMemory] = resource.MustParse("100Mi")
|
||||
podToUpdate.Spec.Containers[0].Resources.Requests = requests
|
||||
_, err = f.Client.Pods(f.Namespace.Name).Update(podToUpdate)
|
||||
Expect(err).To(HaveOccurred())
|
||||
|
||||
By("Ensuring attempts to update pod resource requirements did not change quota usage")
|
||||
err = waitForResourceQuota(f.Client, f.Namespace.Name, quotaName, usedResources)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
By("Deleting the pod")
|
||||
err = f.Client.Pods(f.Namespace.Name).Delete(podName, api.NewDeleteOptions(0))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
Loading…
Reference in New Issue
Block a user