]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Remove those unnecessary statements "return True"
authorJaveme <zhangmei.li@easystack.cn>
Wed, 18 Nov 2015 08:26:08 +0000 (16:26 +0800)
committerJaveme <zhangmei.li@easystack.cn>
Wed, 9 Mar 2016 07:04:39 +0000 (15:04 +0800)
The reasons to remove them:
* These asynchronous API is not necessary to return a value.
* We do not see the purpose of the statements, because it always
  returns true regardless of success or failure.

These statements are unnecessary and misleading, this commit we will
remove these "return True" (Or just remove "True" if it's not at the
end of a function, in order not to change the execution path).

Affected methods:
* delete_volume
* delete_snapshot
* delete_consistencygroup
* update_consistencygroup
* delete_cgsnapshot

Closes-Bug: #1533997
Change-Id: I38bac64b9eb1be6a4756cfcd3894615d2b849551

cinder/tests/unit/test_volume.py
cinder/volume/manager.py

index a330fb7e97dd62032b4f45e95841d3857b0b49ff..91fb4a14a46012eddeebd75cdeafb86d855832bd 100644 (file)
@@ -1101,8 +1101,7 @@ class VolumeTestCase(BaseVolumeTestCase):
             mox.IgnoreArg()).AndRaise(exception.VolumeIsBusy(
                                       volume_name='fake'))
         self.mox.ReplayAll()
-        res = self.volume.delete_volume(self.context, volume_id)
-        self.assertTrue(res)
+        self.volume.delete_volume(self.context, volume_id)
         volume_ref = db.volume_get(context.get_admin_context(), volume_id)
         self.assertEqual(volume_id, volume_ref.id)
         self.assertEqual("available", volume_ref.status)
@@ -1191,7 +1190,7 @@ class VolumeTestCase(BaseVolumeTestCase):
     def test_delete_volume_not_found(self, mock_get_volume):
         """Test delete volume moves on if the volume does not exist."""
         volume_id = '12345678-1234-5678-1234-567812345678'
-        self.assertTrue(self.volume.delete_volume(self.context, volume_id))
+        self.volume.delete_volume(self.context, volume_id)
         self.assertTrue(mock_get_volume.called)
 
     @mock.patch('cinder.volume.drivers.lvm.LVMVolumeDriver.'
index f34d4bb3252c56986da43d803d07257f18be3abb..d833ff4ebd1b21ae5b3770a50038d7819eecf201 100644 (file)
@@ -682,7 +682,7 @@ class VolumeManager(manager.SchedulerDependentManager):
             # be deleted when resuming deletes from init_host().
             LOG.debug("Attempted delete of non-existent volume: %s",
                       volume_id)
-            return True
+            return
 
         if context.project_id != volume.project_id:
             project_id = volume.project_id
@@ -749,7 +749,7 @@ class VolumeManager(manager.SchedulerDependentManager):
             # record to avoid user confusion.
             self._clear_db(context, is_migrating_dest, volume,
                            'available')
-            return True
+            return
         except Exception:
             with excutils.save_and_reraise_exception():
                 # If this is a destination volume, we have to clear the
@@ -806,7 +806,6 @@ class VolumeManager(manager.SchedulerDependentManager):
             self.publish_service_capabilities(context)
 
         LOG.info(_LI("Deleted volume successfully."), resource=volume)
-        return True
 
     def _clear_db(self, context, is_migrating_dest, volume_ref, status):
         # This method is called when driver.unmanage() or
@@ -906,7 +905,7 @@ class VolumeManager(manager.SchedulerDependentManager):
                       resource=snapshot)
             snapshot.status = 'available'
             snapshot.save()
-            return True
+            return
         except Exception:
             with excutils.save_and_reraise_exception():
                 snapshot.status = 'error_deleting'
@@ -941,7 +940,6 @@ class VolumeManager(manager.SchedulerDependentManager):
             QUOTAS.commit(context, reservations, project_id=project_id)
         LOG.info(_LI("Delete snapshot completed successfully"),
                  resource=snapshot)
-        return True
 
     def attach_volume(self, context, volume_id, instance_uuid, host_name,
                       mountpoint, mode):
@@ -2860,8 +2858,6 @@ class VolumeManager(manager.SchedulerDependentManager):
                  resource={'type': 'consistency_group',
                            'id': group.id})
 
-        return True
-
     def update_consistencygroup(self, context, group,
                                 add_volumes=None, remove_volumes=None):
         """Updates consistency group.
@@ -3006,8 +3002,6 @@ class VolumeManager(manager.SchedulerDependentManager):
                  resource={'type': 'consistency_group',
                            'id': group.id})
 
-        return True
-
     def create_cgsnapshot(self, context, cgsnapshot):
         """Creates the cgsnapshot."""
         caller_context = context
@@ -3215,8 +3209,6 @@ class VolumeManager(manager.SchedulerDependentManager):
         self._notify_about_cgsnapshot_usage(context, cgsnapshot, "delete.end",
                                             snapshots)
 
-        return True
-
     def update_migrated_volume(self, ctxt, volume, new_volume,
                                volume_status):
         """Finalize migration process on backend device."""