]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Remove name_id when creating volume with cache enabled
authorpeter_wang <peter.wang13@emc.com>
Mon, 21 Dec 2015 10:37:12 +0000 (05:37 -0500)
committerpeter_wang <peter.wang13@emc.com>
Wed, 23 Dec 2015 07:12:55 +0000 (02:12 -0500)
When image_volume_cache_enabled = True, Cinder will create
a cached image volume. But when creating this image volume,
the name_id is set to id of newly created volume, which causes
the image volume is unable to be created in the underlying storage
system.

This fix will remove the name_id so that volume.name can refer to
correct LUN on storage system

Also, a minor fix: passing volume.id to delete_volume since
it only accept volume id.

Change-Id: Ib47b189a525d8a9bd9026cc20f62542aede9c9d4
Closes-bug: 1528087

cinder/volume/manager.py

index 180d20743fdb1b6346d1fa2f7c8fb892f5d4c689..21d48c0b1c0e7e2129b5de95d6e1c3215965e332 100644 (file)
@@ -1073,11 +1073,11 @@ class VolumeManager(manager.SchedulerDependentManager):
         reserve_opts = {'volumes': 1, 'gigabytes': volume.size}
         QUOTAS.add_volume_type_opts(ctx, reserve_opts, volume_type_id)
         reservations = QUOTAS.reserve(ctx, **reserve_opts)
-
         try:
             new_vol_values = dict(volume.items())
             new_vol_values.pop('id', None)
             new_vol_values.pop('_name_id', None)
+            new_vol_values.pop('name_id', None)
             new_vol_values.pop('volume_type', None)
             new_vol_values.pop('name', None)
 
@@ -1122,7 +1122,7 @@ class VolumeManager(manager.SchedulerDependentManager):
                           {'volume_id': volume.id,
                            'image_id': image_meta['id']})
             try:
-                self.delete_volume(ctx, image_volume)
+                self.delete_volume(ctx, image_volume.id)
             except exception.CinderException:
                 LOG.exception(_LE('Could not delete the image volume %(id)s.'),
                               {'id': volume.id})