when create volume from image, image is fetched twice

Bug #1977868 reported by norman shen
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Cinder
New
Wishlist
Unassigned

Bug Description

hello,

I am reading cinder source code got confused on creating volume from an image. The problem I am seeing is the image is fetched.

The first time is here

            if not cloned:
                try:
                    with image_utils.TemporaryImages.fetch(
                            image_service, context, image_id,
                            backend_name) as tmp_image:
                        if CONF.verify_glance_signatures != 'disabled':
                            # Verify image signature via reading content from
                            # temp image, and store the verification flag if
                            # required.
                            verified = \
                                image_utils.verify_glance_image_signature(
                                    context, image_service,
                                    image_id, tmp_image)
                            self.db.volume_glance_metadata_bulk_create(
                                context, volume.id,
                                {'signature_verified': verified})
                        # Try to create the volume as the minimal size,
                        # then we can extend once the image has been
                        # downloaded.
                        data = image_utils.qemu_img_info(tmp_image)

                        virtual_size = image_utils.check_virtual_size(
                            data.virtual_size, volume.size, image_id)

                        if should_create_cache_entry:
                            if virtual_size and virtual_size != original_size:
                                volume.size = virtual_size
                                volume.save()
                        model_update = self._create_from_image_download(
                            context,
                            volume,
                            image_location,
                            image_meta,
                            image_service

and the second time is here

    def _copy_image_to_volume(self,
                              context: context.RequestContext,
                              volume: Volume,
                              image_service: Any,
                              image_id: str,
                              encrypted: bool = False) -> None:

        tmp_dir = volume_utils.image_conversion_dir()

        with tempfile.NamedTemporaryFile(dir=tmp_dir) as tmp:
            image_utils.fetch_to_raw(context, image_service, image_id,
                                     tmp.name,
                                     self.configuration.volume_dd_blocksize,
                                     size=volume.size)

            if encrypted:
                self._encrypt_image(context, volume, tmp_dir, tmp.name)

            @utils.retry(exception.VolumeIsBusy,
                         self.configuration.rados_connection_interval,
                         self.configuration.rados_connection_retries)
            def _delete_volume(volume: Volume) -> None:
                self.delete_volume(volume)

            _delete_volume(volume)

IMO downloading image two times is not very efficient especially the image type is raw and original size is huge.

Tags: image
Changed in cinder:
importance: Undecided → Wishlist
tags: added: image
description: updated
Revision history for this message
Aravindh (highlow7) wrote :

Is this still an issue?

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.