]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Catch vol not found in SolidFire transfer
authorJohn Griffith <john.griffith8@gmail.com>
Fri, 15 Aug 2014 23:26:15 +0000 (17:26 -0600)
committerJohn Griffith <john.griffith8@gmail.com>
Sun, 17 Aug 2014 18:50:24 +0000 (12:50 -0600)
The accept_transfer call in SolidFire wasn't catching
the volume_not found exception like it should be (and
like other methods do).

This patch just adds a check for volume is None on the
get_volume call during accept_transfer and raises an
appropriate exception if we run into that case.

While we're at it, add some more detail to the "NotFound"
error messages to include the driver operation as per
request of reviewers.

Change-Id: Ie6b56953028865eb06ebdaae3416339b8a371351
Closes-Bug: #1357261

cinder/tests/test_solidfire.py
cinder/volume/drivers/solidfire.py

index 09f0dca4e5a3044c621bdc75221eb4a96e83e850..819673a2b9305d6cef372d31fb4d1f7475501626 100644 (file)
@@ -511,6 +511,22 @@ class SolidFireVolumeTestCase(test.TestCase):
                                              'new_user', 'new_project'),
                          expected)
 
+    def test_accept_transfer_volume_not_found_raises(self):
+        sfv = SolidFireDriver(configuration=self.configuration)
+        self.stubs.Set(SolidFireDriver, '_issue_api_request',
+                       self.fake_issue_api_request)
+        testvol = {'project_id': 'testprjid',
+                   'name': 'test_volume',
+                   'size': 1,
+                   'id': 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa',
+                   'created_at': timeutils.utcnow()}
+        self.assertRaises(exception.VolumeNotFound,
+                          sfv.accept_transfer,
+                          self.ctxt,
+                          testvol,
+                          'new_user',
+                          'new_project')
+
     def test_retype(self):
         sfv = SolidFireDriver(configuration=self.configuration)
         self.stubs.Set(SolidFireDriver, '_issue_api_request',
index 279eceb6cf8646b519c2cf7e8ee09322ce4aca2d..15b2fd1f8a0086dc414efccb8e610517482369ae 100644 (file)
@@ -70,10 +70,11 @@ class SolidFireDriver(SanISCSIDriver):
         1.1 - Refactor, clone support, qos by type and minor bug fixes
         1.2 - Add xfr and retype support
         1.2.1 - Add export/import support
+        1.2.2 - Catch VolumeNotFound on accept xfr
 
     """
 
-    VERSION = '1.2.1'
+    VERSION = '1.2.2'
 
     sf_qos_dict = {'slow': {'minIOPS': 100,
                             'maxIOPS': 200,
@@ -456,6 +457,9 @@ class SolidFireDriver(SanISCSIDriver):
         return qos
 
     def _get_sf_volume(self, uuid, params):
+        # TODO(jdg): Going to fix this shortly to not iterate
+        # but instead use the cinder UUID and our internal
+        # mapping to get this more efficiently
         data = self._issue_api_request('ListVolumesForAccount', params)
         if 'result' not in data:
             msg = _("Failed to get SolidFire Volume: %s") % data
@@ -559,7 +563,8 @@ class SolidFireDriver(SanISCSIDriver):
         sfaccount = self._get_sfaccount(volume['project_id'])
         if sfaccount is None:
             LOG.error(_("Account for Volume ID %s was not found on "
-                        "the SolidFire Cluster!") % volume['id'])
+                        "the SolidFire Cluster while attempting "
+                        "delete_volume operation!") % volume['id'])
             LOG.error(_("This usually means the volume was never "
                         "successfully created."))
             return
@@ -577,7 +582,8 @@ class SolidFireDriver(SanISCSIDriver):
                 raise exception.SolidFireAPIException(msg)
         else:
             LOG.error(_("Volume ID %s was not found on "
-                        "the SolidFire Cluster!"), volume['id'])
+                        "the SolidFire Cluster while attempting "
+                        "delete_volume operation!"), volume['id'])
 
         LOG.debug("Leaving SolidFire delete_volume")
 
@@ -651,7 +657,8 @@ class SolidFireDriver(SanISCSIDriver):
 
         if sf_vol is None:
             LOG.error(_("Volume ID %s was not found on "
-                        "the SolidFire Cluster!"), volume['id'])
+                        "the SolidFire Cluster while attempting "
+                        "extend_volume operation!"), volume['id'])
             raise exception.VolumeNotFound(volume_id=volume['id'])
 
         params = {
@@ -715,7 +722,8 @@ class SolidFireDriver(SanISCSIDriver):
         sf_vol = self._get_sf_volume(volume['id'], params)
         if sf_vol is None:
             LOG.error(_("Volume ID %s was not found on "
-                        "the SolidFire Cluster!"), volume['id'])
+                        "the SolidFire Cluster while attempting "
+                        "attach_volume operation!"), volume['id'])
             raise exception.VolumeNotFound(volume_id=volume['id'])
 
         attributes = sf_vol['attributes']
@@ -740,7 +748,8 @@ class SolidFireDriver(SanISCSIDriver):
         sf_vol = self._get_sf_volume(volume['id'], params)
         if sf_vol is None:
             LOG.error(_("Volume ID %s was not found on "
-                        "the SolidFire Cluster!"), volume['id'])
+                        "the SolidFire Cluster while attempting "
+                        "detach_volume operation!"), volume['id'])
             raise exception.VolumeNotFound(volume_id=volume['id'])
 
         attributes = sf_vol['attributes']
@@ -762,7 +771,11 @@ class SolidFireDriver(SanISCSIDriver):
         sfaccount = self._get_sfaccount(volume['project_id'])
         params = {'accountID': sfaccount['accountID']}
         sf_vol = self._get_sf_volume(volume['id'], params)
-
+        if sf_vol is None:
+            LOG.error(_("Volume ID %s was not found on "
+                        "the SolidFire Cluster while attempting "
+                        "accept_transfer operation!"), volume['id'])
+            raise exception.VolumeNotFound(volume_id=volume['id'])
         if new_project != volume['project_id']:
             # do a create_sfaccount here as this tenant
             # may not exist on the cluster yet
@@ -906,7 +919,8 @@ class SolidFireDriver(SanISCSIDriver):
         sfaccount = self._get_sfaccount(volume['project_id'])
         if sfaccount is None:
             LOG.error(_("Account for Volume ID %s was not found on "
-                        "the SolidFire Cluster!") % volume['id'])
+                        "the SolidFire Cluster while attempting "
+                        "unmanage operation!") % volume['id'])
             raise exception.SolidFireAPIException("Failed to find account "
                                                   "for volume.")