diff --git a/daemon/containerd/image_children.go b/daemon/containerd/image_children.go index d00e5e1c20..488b5b158c 100644 --- a/daemon/containerd/image_children.go +++ b/daemon/containerd/image_children.go @@ -15,9 +15,7 @@ import ( // Children returns a slice of image ID which rootfs is a superset of the // rootfs of the given image ID, excluding images with exactly the same rootfs. // Called from list.go to filter containers. -func (i *ImageService) Children(id image.ID) []image.ID { - ctx := context.TODO() - +func (i *ImageService) Children(ctx context.Context, id image.ID) []image.ID { target, err := i.resolveDescriptor(ctx, id.String()) if err != nil { logrus.WithError(err).Error("failed to get parent image") diff --git a/daemon/image_service.go b/daemon/image_service.go index f7160bbb37..f0622d719f 100644 --- a/daemon/image_service.go +++ b/daemon/image_service.go @@ -75,7 +75,7 @@ type ImageService interface { GetRepository(ctx context.Context, ref reference.Named, authConfig *registry.AuthConfig) (distribution.Repository, error) DistributionServices() images.DistributionServices - Children(id image.ID) []image.ID + Children(ctx context.Context, id image.ID) []image.ID Cleanup() error StorageDriver() string UpdateConfig(maxDownloads, maxUploads int) diff --git a/daemon/images/service.go b/daemon/images/service.go index e97964abf4..19cbfa0263 100644 --- a/daemon/images/service.go +++ b/daemon/images/service.go @@ -109,7 +109,7 @@ func (i *ImageService) CountImages() int { // Children returns the children image.IDs for a parent image. // called from list.go to filter containers // TODO: refactor to expose an ancestry for image.ID? -func (i *ImageService) Children(id image.ID) []image.ID { +func (i *ImageService) Children(_ context.Context, id image.ID) []image.ID { return i.imageStore.Children(id) } diff --git a/daemon/list.go b/daemon/list.go index 6ebcb0c0ea..cefb06395b 100644 --- a/daemon/list.go +++ b/daemon/list.go @@ -328,7 +328,7 @@ func (daemon *Daemon) foldFilter(ctx context.Context, view *container.View, conf return nil } // Then walk down the graph and put the imageIds in imagesFilter - populateImageFilterByParents(imagesFilter, img.ID(), daemon.imageService.Children) + populateImageFilterByParents(ctx, imagesFilter, img.ID(), daemon.imageService.Children) return nil }) } @@ -594,10 +594,10 @@ func (daemon *Daemon) refreshImage(ctx context.Context, s *container.Snapshot, f return &c, nil } -func populateImageFilterByParents(ancestorMap map[image.ID]bool, imageID image.ID, getChildren func(image.ID) []image.ID) { +func populateImageFilterByParents(ctx context.Context, ancestorMap map[image.ID]bool, imageID image.ID, getChildren func(context.Context, image.ID) []image.ID) { if !ancestorMap[imageID] { - for _, id := range getChildren(imageID) { - populateImageFilterByParents(ancestorMap, id, getChildren) + for _, id := range getChildren(ctx, imageID) { + populateImageFilterByParents(ctx, ancestorMap, id, getChildren) } ancestorMap[imageID] = true }