]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Redundant size check in volume restore api
authorling-yun <zengyunling@huawei.com>
Wed, 25 Dec 2013 08:03:27 +0000 (16:03 +0800)
committerling-yun <zengyunling@huawei.com>
Mon, 30 Dec 2013 13:02:12 +0000 (21:02 +0800)
In cinder volume restore api, we do twice size check when restore volume
with a given volume uuid. It's necessary to remove the redundant check.

Change-Id: I8f240b2c0d1014d212ff56c2c9b5e193f9d552bd
Closes-Bug: #1264053

cinder/backup/api.py

index 2c2d501153285ce7666a2f4e9a8ff93655bc4fb0..f019dd6a2b7e374d47fed36bc1fe8011d0246678 100644 (file)
@@ -165,12 +165,6 @@ class API(base.Base):
                 greenthread.sleep(1)
         else:
             volume = self.volume_api.get(context, volume_id)
-            volume_size = volume['size']
-            if volume_size < size:
-                err = (_('volume size %(volume_size)d is too small to restore '
-                         'backup of size %(size)d.') %
-                       {'volume_size': volume_size, 'size': size})
-                raise exception.InvalidVolume(reason=err)
 
         if volume['status'] != "available":
             msg = _('Volume to be restored to must be available')
@@ -179,8 +173,9 @@ class API(base.Base):
         LOG.debug('Checking backup size %s against volume size %s',
                   size, volume['size'])
         if size > volume['size']:
-            msg = _('Volume to be restored to is smaller '
-                    'than the backup to be restored')
+            msg = (_('volume size %(volume_size)d is too small to restore '
+                     'backup of size %(size)d.') %
+                   {'volume_size': volume['size'], 'size': size})
             raise exception.InvalidVolume(reason=msg)
 
         LOG.audit(_("Overwriting volume %(volume_id)s with restore of "