From b7f0946bbd071bc76809eca440ab7d21a03eb1a3 Mon Sep 17 00:00:00 2001 From: "Kevin L. Mitchell" Date: Fri, 11 May 2012 15:30:14 -0500 Subject: Finish quota refactor. Finishes quota refactoring by making use of the new quota infrastructure. Partially implements blueprint quota-refactor (the final piece is to remove the old quota architecture). This change is fairly substantial. To make it easier to review, it has been broken up into 3 parts. This is the second part. Change-Id: I1c8b43198f0d44e9e13a45575361aa043fd0639e --- nova/db/sqlalchemy/api.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'nova/db') diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index c555c73c8..56a25ad71 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -2543,6 +2543,10 @@ def quota_reserve(context, resources, quotas, deltas, expire, session=session, save=False) refresh = True + elif usages[resource].in_use < 0: + # Negative in_use count indicates a desync, so try to + # heal from that... + refresh = True elif usages[resource].until_refresh is not None: usages[resource].until_refresh -= 1 if usages[resource].until_refresh <= 0: @@ -2607,7 +2611,7 @@ def quota_reserve(context, resources, quotas, deltas, expire, # they're not invalidated by being over-quota. # Create the reservations - if not unders and not overs: + if not overs: reservations = [] for resource, delta in deltas.items(): reservation = reservation_create(elevated, @@ -2638,7 +2642,8 @@ def quota_reserve(context, resources, quotas, deltas, expire, usage_ref.save(session=session) if unders: - raise exception.InvalidQuotaValue(unders=sorted(unders)) + LOG.warning(_("Change will make usage less than 0 for the following " + "resources: %(unders)s") % locals()) if overs: usages = dict((k, dict(in_use=v['in_use'], reserved=v['reserved'])) for k, v in usages.items()) -- cgit