Don't disallow quota deletion if allocated < 0

Due to the race condition http://bugs.launchpad.net/cinder/+bug/1552944,
it's possible that a volume delete on a project at the same time as a
change to/from a -1 limit on the project could double count the change
in allocated value. This has the possibility to set allocated < 0, and
in order to handle this situation as gracefully as possible, we should
not disallow quota deletion in the case that allocated < 0.

Change-Id: Ic35ff9671024aa1cecc04b205d1b7cba56bbea61
Closes-Bug: #1554173
This commit is contained in:
Ryan McNair 2016-03-07 18:42:22 +00:00
parent 0a9943b52a
commit edff6fbf5d

View File

@ -395,7 +395,7 @@ class QuotaSetsController(wsgi.Controller):
# deleted first.
for res, value in project_quotas.items():
if 'allocated' in project_quotas[res].keys():
if project_quotas[res]['allocated'] != 0:
if project_quotas[res]['allocated'] > 0:
msg = _("About to delete child projects having "
"non-zero quota. This should not be performed")
raise webob.exc.HTTPBadRequest(explanation=msg)