]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Do not query reservations table when counting resources
authorSalvatore Orlando <salv.orlando@gmail.com>
Wed, 19 Aug 2015 13:10:08 +0000 (06:10 -0700)
committerHenry Gessau <gessau@cisco.com>
Thu, 20 Aug 2015 13:55:25 +0000 (09:55 -0400)
Reservations are temporarily disabled, and therefore querying them
is pointless, and potentially harmful.

Change-Id: Iab1d0ffdc54cb5bd06a0d4fbd4eb095ac4b754b8
Related-Bug: #1486134

neutron/quota/resource.py

index 0030307ba694f448ad5f54ebb84b0ade4f94db99..1b5e73939bf71909ac0c788c9860fbde78664dcc 100644 (file)
@@ -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. "