Do not decompress 'compressed' containers

Do not decompress the image if container_format is compressed

Change-Id: I913d9bf11479d2519f7887e42626e9e386d83d7a
This commit is contained in:
Erno Kuvaja 2020-04-07 10:31:48 +01:00
parent 2d21685ee4
commit a2e0fb61e9
2 changed files with 10 additions and 0 deletions

View File

@ -628,6 +628,11 @@ only compressed images.
where "service_role" is the role which is created for the service user
and assigned to trusted services.
.. note::
The plugin will not decompressed images which container_format is set
to 'compressed' to maintain the original intent of the image creator.
To use the Image Decompression Plugin, the following configuration is
required.

View File

@ -121,6 +121,11 @@ class _DecompressImage(task.Task):
# account and handle the paths here.
src_path = file_path.split('file://')[-1]
self.dest_path = "%(path)s.uc" % {'path': src_path}
image = self.image_repo.get(self.image_id)
# NOTE(jokke): If the container format is 'compressed' the image is
# expected to be compressed so lets not decompress it.
if image.container_format == 'compressed':
return "file://%s" % src_path
head = None
with open(src_path, 'rb') as fd:
head = fd.read(MAX_HEADER)