diff --git a/daemon/containerd/image_children.go b/daemon/containerd/image_children.go index d00e5e1c20603abace3d9804885f8c187294c8d3..488b5b158c8f9511f4097eaa86bcb3981ce10564 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 f7160bbb3704b4d0297b5b957bc1b9faa59afaf9..f0622d719f92997bea153b10bbb5512edb75972e 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 e97964abf4e9d683f2080d04d682240a9171b54f..19cbfa02630f87b445042125af4a9c2c6184107b 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 6ebcb0c0eabf7d07f2eb7bf02f04bfe639d9903f..cefb06395b65f99a90298f8a47625f14dcde8c9b 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 }