]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
After commiting quota we should avoid certain reverts
authorJoshua Harlow <harlowja@yahoo-inc.com>
Tue, 1 Oct 2013 22:53:30 +0000 (15:53 -0700)
committerJoshua Harlow <harlowja@yahoo-inc.com>
Tue, 1 Oct 2013 23:53:52 +0000 (16:53 -0700)
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

cinder/context.py
cinder/volume/flows/create_volume/__init__.py

index 797bfc71bc817f3ba2d02fe87f4d105081d85d88..32610b5043c87885fbba08fea8e27dcd61dd6307 100644 (file)
@@ -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
index de2192c48b918507cbeea40dd68f7039ca36a936..7883f8c6d09dd4a09d15480d7e530113ba6f5c1b 100644 (file)
@@ -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):