Quota scopes cannot handle the transition case from one scope to another when the target object is updated. #124436
Labels
kind/bug
Categorizes issue or PR as related to a bug.
needs-triage
Indicates an issue or PR lacks a `triage/foo` label and requires one.
sig/api-machinery
Categorizes an issue or PR as relevant to SIG API Machinery.
What happened?
I create 2 quotas with different scopes, one is Terminating, and the other is NotTerminating. I create a pod that belongs to NotTerminating, then update the pod's spec.activeDeadlineSeconds with 5, the pod should belong to Terminating. But the quota is not updated.
What did you expect to happen?
Quota scopes can handle the transition case from one scope to another when the target object is updated.
How can we reproduce it (as minimally and precisely as possible)?
kubectl patch pod test-pod -p '{"spec":{"activeDeadlineSeconds":5}}'
Anything else we need to know?
The root cause is, when the pod is updated, the delta is calculated based on the old object and the new object, it doesn't consider the scope change where the updated object belongs to, so the final delta is not correct.
In this case, the final delta is zero, so the terminating quota is not updated.
Related k/k code:
kubernetes/staging/src/k8s.io/apiserver/pkg/admission/plugin/resourcequota/controller.go
Lines 495 to 558 in 5a31a46
When I implement #124360, I find this issue.
Kubernetes version
Cloud provider
OS version
Install tools
Container runtime (CRI) and version (if applicable)
Related plugins (CNI, CSI, ...) and versions (if applicable)
The text was updated successfully, but these errors were encountered: