From 09852988d131bdd61e5685541fd2cec1e0e7b73d Mon Sep 17 00:00:00 2001 From: Salvatore Orlando Date: Wed, 19 Aug 2015 06:10:08 -0700 Subject: [PATCH] Do not query reservations table when counting resources Reservations are temporarily disabled, and therefore querying them is pointless, and potentially harmful. Change-Id: Iab1d0ffdc54cb5bd06a0d4fbd4eb095ac4b754b8 Related-Bug: #1486134 --- neutron/quota/resource.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/neutron/quota/resource.py b/neutron/quota/resource.py index 0030307ba69..1b5e73939bf 100644 --- a/neutron/quota/resource.py +++ b/neutron/quota/resource.py @@ -232,11 +232,8 @@ class TrackedResource(BaseResource): {'tenant_id': tenant_id, 'resource': self.name}) in_use = context.session.query(self._model_class).filter_by( tenant_id=tenant_id).count() - reservations = quota_api.get_reservations_for_resources( - context, tenant_id, [self.name]) - reserved = reservations.get(self.name, 0) # Update quota usage - return self._resync(context, tenant_id, in_use, reserved) + return self._resync(context, tenant_id, in_use, reserved=0) def count(self, context, _plugin, tenant_id, resync_usage=False): """Return the current usage count for the resource. @@ -266,21 +263,20 @@ class TrackedResource(BaseResource): 'tenant_id': tenant_id}) in_use = context.session.query(self._model_class).filter_by( tenant_id=tenant_id).count() - reservations = quota_api.get_reservations_for_resources( - context, tenant_id, [self.name]) - reserved = reservations.get(self.name, 0) # Update quota usage, if requested (by default do not do that, as # typically one counts before adding a record, and that would mark # the usage counter as dirty again) if resync_usage or not usage_info: usage_info = self._resync(context, tenant_id, - in_use, reserved) + in_use, reserved=0) else: + # NOTE(salv-orlando): Passing 0 for reserved amount as + # reservations are currently not supported usage_info = quota_api.QuotaUsageInfo(usage_info.resource, usage_info.tenant_id, in_use, - reserved, + 0, usage_info.dirty) LOG.debug(("Quota usage for %(resource)s was recalculated. "