From: Joshua Harlow Date: Tue, 1 Oct 2013 22:53:30 +0000 (-0700) Subject: After commiting quota we should avoid certain reverts X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=3814658cec4a075ebef2b7efdcff4b82f7cce830;p=openstack-build%2Fcinder-build.git After commiting quota we should avoid certain reverts After we commit the quota successfully we do not want to set the database volume to destroyed or attempt further rollback of the quota itself to reflect what the code previously did. Closes-Bug: #1230189 Change-Id: I115dc6736b8f2d0d7b2b6f29e9fd1904fd1c6eee --- diff --git a/cinder/context.py b/cinder/context.py index 797bfc71b..32610b504 100644 --- a/cinder/context.py +++ b/cinder/context.py @@ -85,6 +85,7 @@ class RequestContext(object): self.quota_class = quota_class if overwrite or not hasattr(local.store, 'context'): self.update_store() + self.quota_committed = False if service_catalog: # Only include required parts of service_catalog diff --git a/cinder/volume/flows/create_volume/__init__.py b/cinder/volume/flows/create_volume/__init__.py index de2192c48..7883f8c6d 100644 --- a/cinder/volume/flows/create_volume/__init__.py +++ b/cinder/volume/flows/create_volume/__init__.py @@ -573,6 +573,10 @@ class EntryCreateTask(base.CinderTask): # We never produced a result and therefore can't destroy anything. if not result: return + if context.quota_committed: + # Committed quota doesn't rollback as the volume has already been + # created at this point, and the quota has already been absorbed. + return vol_id = result['volume_id'] try: self.db.volume_destroy(context, vol_id) @@ -651,6 +655,10 @@ class QuotaReserveTask(base.CinderTask): # We never produced a result and therefore can't destroy anything. if not result: return + if context.quota_committed: + # The reservations have already been commited and can not be + # rolled back at this point. + return # We actually produced an output that we can revert so lets attempt # to use said output to rollback the reservation. reservations = result['reservations'] @@ -684,6 +692,7 @@ class QuotaCommitTask(base.CinderTask): def __call__(self, context, reservations): QUOTAS.commit(context, reservations) + context.quota_committed = True class VolumeCastTask(base.CinderTask):