when create volume from image, image is fetched twice

Bug #1977868 reported by norman shen
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description


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:
                    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 = \
                                    context, image_service,
                                    image_id, tmp_image)
                                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
                        model_update = self._create_from_image_download(

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,

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

            def _delete_volume(volume: Volume) -> None:


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
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.