Ensure the squashed estimated size is an int
Also adds a test to verify
This commit is contained in:
parent
f439ad7804
commit
a627494e05
2 changed files with 41 additions and 2 deletions
|
@ -5,6 +5,7 @@ from formats.tarimageformatter import TarImageFormatter
|
|||
|
||||
import copy
|
||||
import json
|
||||
import math
|
||||
|
||||
class FileEstimationException(Exception):
|
||||
""" Exception raised by build_docker_load_stream if the estimated size of the layer TAR
|
||||
|
@ -68,6 +69,9 @@ class SquashedDockerImage(TarImageFormatter):
|
|||
image_json = get_image_json(image)
|
||||
estimated_file_size += image_json.get('Size', 0) * SquashedDockerImage.SIZE_MULTIPLIER
|
||||
|
||||
# Make sure the estimated file size is an integer number of bytes.
|
||||
estimated_file_size = int(math.ceil(estimated_file_size))
|
||||
|
||||
yield self.tar_file_header(synthetic_image_id + '/layer.tar', estimated_file_size)
|
||||
|
||||
# Yield the contents of the merged layer.
|
||||
|
|
Reference in a new issue