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 committed May 16, 2024
1 parent 632da33 commit a1e2fff
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 @@ -309,7 +309,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 @@ -453,9 +453,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 a1e2fff

Please sign in to comment.