From: lisali Date: Sun, 6 Sep 2015 06:05:22 +0000 (+0000) Subject: Retrieve volume in update_migrated_volume X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=647cff38fe412d2a31c6ed3f77cc1da1e73a8424;p=openstack-build%2Fcinder-build.git Retrieve volume in update_migrated_volume When transferring db volume module through RPC call, it becomes dict objects during RPC call. The attributes/properties of the type can't be used. As a result, to get volume['name'] raises KeyError. The issue is fixed by retrieving volume from db. Using volume version object will fix everything but it is too late in Liberty. To keep code consistency, db.get_volume is used in the fix. Change-Id: I5ac7f083d5b4b7490347069728eb4b938c20885c Closes-bug: 1491210 --- diff --git a/cinder/tests/unit/test_volume.py b/cinder/tests/unit/test_volume.py index b62ac9d0a..981ed81be 100644 --- a/cinder/tests/unit/test_volume.py +++ b/cinder/tests/unit/test_volume.py @@ -4125,11 +4125,12 @@ class VolumeTestCase(BaseVolumeTestCase): volume = tests_utils.create_volume(self.context, size=1, status='available', host=fake_host) - new_volume = tests_utils.create_volume(self.context, size=1, - status='available', - host=fake_new_host) - new_volume['_name_id'] = 'fake_name_id' - new_volume['provider_location'] = 'fake_provider_location' + new_volume = tests_utils.create_volume( + self.context, size=1, + status='available', + provider_location='fake_provider_location', + _name_id='fake_name_id', + host=fake_new_host) fake_update_error = {'_name_id': new_volume['_name_id'], 'provider_location': new_volume['provider_location']} diff --git a/cinder/volume/manager.py b/cinder/volume/manager.py index 2032cf8de..0739e7e95 100644 --- a/cinder/volume/manager.py +++ b/cinder/volume/manager.py @@ -3017,6 +3017,9 @@ class VolumeManager(manager.SchedulerDependentManager): volume_status): """Finalize migration process on backend device.""" model_update = None + # This is temporary fix for bug 1491210. + volume = self.db.volume_get(ctxt, volume['id']) + new_volume = self.db.volume_get(ctxt, new_volume['id']) try: model_update = self.driver.update_migrated_volume(ctxt, volume,