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)
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)
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)
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. NamedTemporaryF ile(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)
def _delete_
IMO downloading image two times is not very efficient especially the image type is raw and original size is huge.