From 520aa08d4222471d599e7d316f35a2dec493254a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Gronowski?= Date: Fri, 14 Apr 2023 13:02:04 +0200 Subject: [PATCH] c8d/prune: Logging fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Use logrus.Fields instead of multiple WithField - Split one giant debug log into one log per image Signed-off-by: Paweł Gronowski --- daemon/containerd/image_prune.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/daemon/containerd/image_prune.go b/daemon/containerd/image_prune.go index 1e6927a615..6da0d2c013 100644 --- a/daemon/containerd/image_prune.go +++ b/daemon/containerd/image_prune.go @@ -79,7 +79,11 @@ func (i *ImageService) pruneUnused(ctx context.Context, filterFunc imageFilterFu // Apply filters for name, img := range imagesToPrune { filteredOut := !filterFunc(img) - logrus.WithField("image", name).WithField("filteredOut", filteredOut).Debug("filtering image") + logrus.WithFields(logrus.Fields{ + "image": name, + "filteredOut": filteredOut, + }).Debug("filtering image") + if filteredOut { delete(imagesToPrune, name) } @@ -107,8 +111,6 @@ func (i *ImageService) pruneUnused(ctx context.Context, filterFunc imageFilterFu } } - logrus.WithField("images", imagesToPrune).Debug("pruning") - possiblyDeletedConfigs := map[digest.Digest]struct{}{} // Workaround for https://github.com/moby/buildkit/issues/3797 @@ -119,6 +121,8 @@ func (i *ImageService) pruneUnused(ctx context.Context, filterFunc imageFilterFu }() for _, img := range imagesToPrune { + logrus.WithField("image", img).Debug("pruning image") + blobs := []ocispec.Descriptor{} err := i.walkPresentChildren(ctx, img.Target, func(_ context.Context, desc ocispec.Descriptor) {