Temp fix for squashed images
This commit is contained in:
parent
b87427aefb
commit
df4ab8565c
1 changed files with 7 additions and 2 deletions
|
@ -19,6 +19,10 @@ class SquashedDockerImage(TarImageFormatter):
|
||||||
command.
|
command.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# TODO(jschorr): Change this multiplier to reflect the 99%-tile of the actual difference between
|
||||||
|
# the uncompressed image size and the Size reported by Docker.
|
||||||
|
SIZE_MULTIPLIER = 2
|
||||||
|
|
||||||
def stream_generator(self, namespace, repository, tag, synthetic_image_id,
|
def stream_generator(self, namespace, repository, tag, synthetic_image_id,
|
||||||
layer_json, get_image_iterator, get_layer_iterator, get_image_json):
|
layer_json, get_image_iterator, get_layer_iterator, get_image_json):
|
||||||
|
|
||||||
|
@ -60,7 +64,7 @@ class SquashedDockerImage(TarImageFormatter):
|
||||||
estimated_file_size += image.storage.uncompressed_size
|
estimated_file_size += image.storage.uncompressed_size
|
||||||
else:
|
else:
|
||||||
image_json = get_image_json(image)
|
image_json = get_image_json(image)
|
||||||
estimated_file_size += image_json.get('Size', 0)
|
estimated_file_size += image_json.get('Size', 0) * SquashedDockerImage.SIZE_MULTIPLIER
|
||||||
|
|
||||||
yield self.tar_file_header(synthetic_image_id + '/layer.tar', estimated_file_size)
|
yield self.tar_file_header(synthetic_image_id + '/layer.tar', estimated_file_size)
|
||||||
|
|
||||||
|
@ -73,7 +77,8 @@ class SquashedDockerImage(TarImageFormatter):
|
||||||
# If the yielded size is more than the estimated size (which is unlikely but possible), then
|
# If the yielded size is more than the estimated size (which is unlikely but possible), then
|
||||||
# raise an exception since the tar header will be wrong.
|
# raise an exception since the tar header will be wrong.
|
||||||
if yielded_size > estimated_file_size:
|
if yielded_size > estimated_file_size:
|
||||||
raise FileEstimationException()
|
message = "Expected %s bytes, found %s bytes" % (estimated_file_size, yielded_size)
|
||||||
|
raise FileEstimationException(message)
|
||||||
|
|
||||||
# If the yielded size is less than the estimated size (which is likely), fill the rest with
|
# If the yielded size is less than the estimated size (which is likely), fill the rest with
|
||||||
# zeros.
|
# zeros.
|
||||||
|
|
Reference in a new issue