replenish quota for service optimize, add testcase
This commit is contained in:
@@ -59,7 +59,7 @@ func PodReplenishmentUpdateFunc(options *ReplenishmentControllerOptions) func(ol
|
||||
oldPod := oldObj.(*api.Pod)
|
||||
newPod := newObj.(*api.Pod)
|
||||
if core.QuotaPod(oldPod) && !core.QuotaPod(newPod) {
|
||||
options.ReplenishmentFunc(options.GroupKind, newPod.Namespace, newPod)
|
||||
options.ReplenishmentFunc(options.GroupKind, newPod.Namespace, oldPod)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -219,13 +219,13 @@ func (r *replenishmentControllerFactory) NewController(options *ReplenishmentCon
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ServiceReplenishmentUpdateFunc will replenish if the old service was quota tracked but the new is not
|
||||
// ServiceReplenishmentUpdateFunc will replenish if the service was quota tracked has changed service type
|
||||
func ServiceReplenishmentUpdateFunc(options *ReplenishmentControllerOptions) func(oldObj, newObj interface{}) {
|
||||
return func(oldObj, newObj interface{}) {
|
||||
oldService := oldObj.(*api.Service)
|
||||
newService := newObj.(*api.Service)
|
||||
if core.QuotaServiceType(oldService) || core.QuotaServiceType(newService) {
|
||||
options.ReplenishmentFunc(options.GroupKind, newService.Namespace, newService)
|
||||
if core.GetQuotaServiceType(oldService) != core.GetQuotaServiceType(newService) {
|
||||
options.ReplenishmentFunc(options.GroupKind, newService.Namespace, nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user