Skip to content

Commit 4bf6987

Browse files
committed
Add debug logging for blob and delta size (authored by Claude)
1 parent e8fbb44 commit 4bf6987

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

image/copy/single.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,20 @@ import (
3232
chunkedToc "go.podman.io/storage/pkg/chunked/toc"
3333
)
3434

35+
// formatSize formats a size in bytes with dynamic units (B, KB, MB, GB)
36+
func formatSize(size int64) string {
37+
const unit = 1024
38+
if size < unit {
39+
return fmt.Sprintf("%d B", size)
40+
}
41+
div, exp := int64(unit), 0
42+
for n := size / unit; n >= unit; n /= unit {
43+
div *= unit
44+
exp++
45+
}
46+
return fmt.Sprintf("%.1f %cB", float64(size)/float64(div), "KMGT"[exp])
47+
}
48+
3549
// imageCopier tracks state specific to a single image (possibly an item of a manifest list)
3650
type imageCopier struct {
3751
c *copier
@@ -804,6 +818,7 @@ func (ic *imageCopier) copyLayer(ctx context.Context, srcIndex int, srcInfo type
804818
return types.BlobInfo{}, "", err
805819
}
806820
if deltaStream != nil {
821+
logrus.Debugf("Applying delta for layer %s (delta size: %.1f MB)", deltaDiffID, float64(matchingDelta.Size)/(1024.0*1024.0))
807822
bar, err := ic.c.createProgressBar(pool, false, matchingDelta, "delta", "done")
808823
if err != nil {
809824
return types.BlobInfo{}, "", err
@@ -990,6 +1005,8 @@ func (ic *imageCopier) copyLayer(ctx context.Context, srcIndex int, srcInfo type
9901005
}
9911006
defer srcStream.Close()
9921007

1008+
logrus.Debugf("Downloading layer %s (blob size: %s)", srcInfo.Digest, formatSize(srcBlobSize))
1009+
9931010
blobInfo, diffIDChan, err := ic.copyLayerFromStream(ctx, srcStream, types.BlobInfo{Digest: srcInfo.Digest, Size: srcBlobSize, MediaType: srcInfo.MediaType, Annotations: srcInfo.Annotations}, diffIDIsNeeded, toEncrypt, bar, srcIndex, emptyLayer)
9941011
if err != nil {
9951012
return types.BlobInfo{}, "", err

0 commit comments

Comments
 (0)