Skip to content

Commit

Permalink
getSize: allow unknown uncompressed size
Browse files Browse the repository at this point in the history
Layers from additional layer store possibly doesn't know the uncompressed size
until it fully downloads the entire contents to the node.

Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
  • Loading branch information
ktock authored and mtrmac committed May 20, 2024
1 parent ebbd025 commit 52101a0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions storage/storage_src.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ func (s *storageImageSource) LayerInfosForCopy(ctx context.Context, instanceDige
return nil, fmt.Errorf("reading layer %q in image %q: %w", layerID, s.image.ID, err)
}
if layer.UncompressedSize < 0 {
return nil, fmt.Errorf("uncompressed size for layer %q is unknown", layerID)
layer.UncompressedSize = -1
}

blobDigest := layer.UncompressedDigest
Expand Down Expand Up @@ -452,9 +452,12 @@ func (s *storageImageSource) getSize() (int64, error) {
if err != nil {
return -1, err
}
if (layer.TOCDigest == "" && layer.UncompressedDigest == "") || layer.UncompressedSize < 0 {
if (layer.TOCDigest == "" && layer.UncompressedDigest == "") || (layer.TOCDigest == "" && layer.UncompressedSize < 0) {
return -1, fmt.Errorf("size for layer %q is unknown, failing getSize()", layerID)
}
if layer.UncompressedSize < 0 {
sum = 0
}
sum += layer.UncompressedSize
if layer.Parent == "" {
break
Expand Down

0 comments on commit 52101a0

Please sign in to comment.