let resourcequota evaluator handle uninitialid pod and pvc

This commit is contained in:
Chao Xu
2017-08-22 21:14:13 -07:00
parent e2de110e26
commit 4928c8d1bf
8 changed files with 117 additions and 16 deletions

View File

@@ -375,8 +375,7 @@ func (e *quotaEvaluator) checkRequest(quotas []api.ResourceQuota, a admission.At
return quotas, nil
}
op := a.GetOperation()
if !evaluator.Handles(op) {
if !evaluator.Handles(a) {
return quotas, nil
}
@@ -463,7 +462,7 @@ func (e *quotaEvaluator) checkRequest(quotas []api.ResourceQuota, a admission.At
return nil, admission.NewForbidden(a, fmt.Errorf("quota usage is negative for resource(s): %s", prettyPrintResourceNames(negativeUsage)))
}
if admission.Update == op {
if admission.Update == a.GetOperation() {
prevItem := a.GetOldObject()
if prevItem == nil {
return nil, admission.NewForbidden(a, fmt.Errorf("unable to get previous usage since prior version of object was not found"))
@@ -529,8 +528,7 @@ func (e *quotaEvaluator) Evaluate(a admission.Attributes) error {
}
// for this kind, check if the operation could mutate any quota resources
// if no resources tracked by quota are impacted, then just return
op := a.GetOperation()
if !evaluator.Handles(op) {
if !evaluator.Handles(a) {
return nil
}