Commit 73257e80 authored by Christos Stavrakakis's avatar Christos Stavrakakis

cyclades: Fix bug with volume quotas

When computing 'cyclades.disk' resource for a 'DESTROY' server action,
count only the volumes that are in the 'IN_USE' status. If the
volumes are not in this status, then a commission has already been
issued for that action. However, there is an exception, if the server is
in 'BUILD' operstate, where we must also count the 'CREATING' volumes.
parent 264f73c7
......@@ -358,6 +358,12 @@ def get_commission_info(resource, action, action_fields=None):
return None
elif action == "DESTROY":
volumes = resource.volumes.filter(deleted=False)
if resource.operstate != "BUILD":
# Count only the volumes that are in the 'IN_USE' status,
# because a pending commission exists for the other volumes.
# The pending commission will be rejected, but
# snf-dispatcher will finally fix the quotas.
volumes = volumes.filter(status="IN_USE")
resources.update(offline_resources)
resources.update(get_volume_resources(volumes))
if resource.operstate in ["STARTED", "BUILD", "ERROR"]:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment