From 45f4f2302cdfa0d3de76d3f956926d3d3ff3739c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Mon, 20 May 2024 19:40:32 +0200 Subject: [PATCH] Don't completely ignore already-computed image size if we see an ALS layer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ... but silently ignore the ALS layer. Also add a FIXME. Signed-off-by: Miloslav Trmač --- storage/storage_src.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/storage/storage_src.go b/storage/storage_src.go index e4fc5b52c..4f501fc22 100644 --- a/storage/storage_src.go +++ b/storage/storage_src.go @@ -456,10 +456,13 @@ func (s *storageImageSource) getSize() (int64, error) { 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 + // FIXME: We allow layer.UncompressedSize < 0 above, because currently images in an Additional Layer Store don’t provide that value. + // Right now, various callers in Podman (and, also, newImage in this package) don’t expect the size computation to fail. + // Should we update the callers, or do we need to continue returning inaccurate information here? Or should we pay the cost + // to compute the size from the diff? + if layer.UncompressedSize >= 0 { + sum += layer.UncompressedSize } - sum += layer.UncompressedSize if layer.Parent == "" { break }