]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Handling re-delete in rackspace db resource
authorVijendar Komalla <vijendar.komalla@RACKSPACE.COM>
Wed, 21 Aug 2013 13:55:43 +0000 (08:55 -0500)
committerVijendar Komalla <vijendar.komalla@RACKSPACE.COM>
Wed, 21 Aug 2013 13:55:53 +0000 (08:55 -0500)
Current implementation of db resource throws exception if the
resource was already deleted(All the other resources are not
throwing). This fix is to make db resource behavior similar to
other resources.

Fixes Bug #1197077

Change-Id: I4537180115400e6f6183e72a74bdd3ada220a3fa

heat/engine/resources/rackspace/clouddatabase.py
heat/tests/test_clouddatabase.py

index ef344b92de6e27ebdd143e62f6622325b7dd98b8..f17cd701242cb1ea8d16502b8ea018b4aa03644e 100644 (file)
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
+try:
+    from pyrax.exceptions import NotFound
+except ImportError:
+    # fake exception for testing without pyrax
+    class NotFound(Exception):
+        pass
+
 from heat.common import exception
 from heat.engine.resources.rackspace import rackspace_resource
 from heat.openstack.common import log as logging
@@ -174,12 +181,13 @@ class CloudDBInstance(rackspace_resource.RackspaceResource):
         Delete a Rackspace Cloud DB Instance.
         '''
         logger.debug("CloudDBInstance handle_delete called.")
-        sqlinstancename = self.properties['InstanceName']
         if self.resource_id is None:
-            logger.debug("resource_id is null and returning without delete.")
-            raise exception.ResourceNotFound(resource_name=sqlinstancename,
-                                             stack_name=self.stack.name)
-        instances = self.cloud_db().delete(self.resource_id)
+            return
+
+        try:
+            instances = self.cloud_db().delete(self.resource_id)
+        except NotFound:
+            pass
         self.resource_id = None
 
     def validate(self):
index 48218914452368fa8b741be0efba89695cd666e3..365be7bae8f9a1c106a655f12b7761399e4a1993 100644 (file)
@@ -13,7 +13,6 @@
 #    under the License.
 
 
-from heat.common import exception
 from heat.common import template_format
 from heat.engine import parser
 from heat.engine import environment
@@ -142,7 +141,7 @@ class CloudDBInstanceTest(HeatTestCase):
         instance = self._setup_test_clouddbinstance('dbinstance_delete')
         instance.resource_id = None
         self.m.ReplayAll()
-        self.assertRaises(exception.ResourceNotFound, instance.handle_delete)
+        instance.handle_delete()
         self.m.VerifyAll()
 
     def test_attribute_not_found(self):