c8d/pull: Show progress for non-layer blobs

Use the same logic as push for determining whether a progress should be
shown for a blob.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
Paweł Gronowski
2025-04-04 15:38:45 +02:00
parent c95e17638f
commit 7acef8101e
3 changed files with 31 additions and 16 deletions

View File

@@ -117,13 +117,12 @@ func (i *ImageService) pullTag(ctx context.Context, ref reference.Named, platfor
}
jobs := newJobs()
h := c8dimages.HandlerFunc(func(ctx context.Context, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) {
if c8dimages.IsLayerType(desc.MediaType) {
opts = append(opts, containerd.WithImageHandler(c8dimages.HandlerFunc(func(ctx context.Context, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) {
if showBlobProgress(desc) {
jobs.Add(desc)
}
return nil, nil
})
opts = append(opts, containerd.WithImageHandler(h))
})))
pp := &pullProgress{
store: i.content,

View File

@@ -149,19 +149,13 @@ func (i *ImageService) pushRef(ctx context.Context, targetRef reference.Named, p
return err
}
addLayerJobs := c8dimages.HandlerFunc(
func(ctx context.Context, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) {
switch {
case c8dimages.IsIndexType(desc.MediaType),
c8dimages.IsManifestType(desc.MediaType),
c8dimages.IsConfigType(desc.MediaType):
default:
jobsQueue.Add(desc)
}
addLayerJobs := c8dimages.HandlerFunc(func(ctx context.Context, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) {
if showBlobProgress(desc) {
jobsQueue.Add(desc)
}
return nil, nil
},
)
return nil, nil
})
handlerWrapper := func(h c8dimages.Handler) c8dimages.Handler {
return c8dimages.Handlers(addLayerJobs, h)

View File

@@ -337,3 +337,25 @@ func (combined combinedProgress) UpdateProgress(ctx context.Context, ongoing *jo
}
return nil
}
// showBlobProgress determines if the progress of pulling/pushing blob should be shown.
// Only indexes, manifests, and configs are hidden to align with the pre-containerd behavior.
// They are small enough JSON files so it's fine to not show them.
// We mostly care about bigger content like layers or other blobs.
func showBlobProgress(desc ocispec.Descriptor) bool {
switch {
case c8dimages.IsLayerType(desc.MediaType):
// Fast path: we always show progress for layers.
//
// Note: We can't just plainly check for c8dimages.IsLayerType alone
// because it wouldn't account for other potentially big blobs like
// artifacts or non-standard images.
return true
case c8dimages.IsIndexType(desc.MediaType),
c8dimages.IsManifestType(desc.MediaType),
c8dimages.IsConfigType(desc.MediaType):
return false
default:
return true
}
}