Merge pull request #10050 from Luap99/image-prune-panic

Fix possible panic in libpod/image/prune.go
This commit is contained in:
OpenShift Merge Robot 2021-04-16 07:43:38 -04:00 committed by GitHub
commit 35b62ef19f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -134,10 +134,11 @@ func (ir *Runtime) PruneImages(ctx context.Context, all bool, filter []string) (
}
nameOrID := img.ID()
s, err := img.Size(ctx)
imgSize := *s
imgSize := uint64(0)
if err != nil {
logrus.Warnf("Failed to collect image size for: %s, %s", nameOrID, err)
imgSize = 0
} else {
imgSize = *s
}
if err := img.Remove(ctx, false); err != nil {
if errors.Cause(err) == storage.ErrImageUsedByContainer {