c8d/prune: Logging fixes

- Use logrus.Fields instead of multiple WithField
- Split one giant debug log into one log per image

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
Paweł Gronowski 2023-04-14 13:02:04 +02:00
parent 52af6d957e
commit 520aa08d42
No known key found for this signature in database
GPG key ID: B85EFCFE26DEF92A

View file

@ -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) {