]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Retrieve volume in update_migrated_volume
authorlisali <xiaoyan.li@intel.com>
Sun, 6 Sep 2015 06:05:22 +0000 (06:05 +0000)
committerLisaLi <xiaoyan.li@intel.com>
Fri, 11 Sep 2015 06:36:20 +0000 (06:36 +0000)
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

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

index b62ac9d0aced395427780aec49dc8be561c9fd23..981ed81beb8306b269652ed6f33a807a5a492586 100644 (file)
@@ -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']}
index 2032cf8dea4c2c3b97c3c3d7a1e18d211b24c7b4..0739e7e951d212b6d474836312e249369be79284 100644 (file)
@@ -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,