From 5fe07c1be34a73c457bd8e6b8a86bfc6e53567d5 Mon Sep 17 00:00:00 2001 From: ling-yun Date: Wed, 25 Dec 2013 16:03:27 +0800 Subject: [PATCH] Redundant size check in volume restore api 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 | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/cinder/backup/api.py b/cinder/backup/api.py index 2c2d50115..f019dd6a2 100644 --- a/cinder/backup/api.py +++ b/cinder/backup/api.py @@ -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 " -- 2.45.2