Skip to content

Commit

Permalink
Merge pull request #8172 from rhatdan/storage
Browse files Browse the repository at this point in the history
[NO TESTS NEEDED] allow the removal of storage images
  • Loading branch information
openshift-merge-robot authored Mar 8, 2021
2 parents ff46d13 + e9db604 commit 021ff99
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions libpod/runtime_img.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,15 @@ func (r *Runtime) LoadImageFromSingleImageArchive(ctx context.Context, writer io
return "", errors.Wrapf(saveErr, "error pulling image")
}

// RemoveImageFromStorage goes directly to storage and attempts to remove
// the specified image. This is dangerous and should only be done if libpod
// reports that image is not known. This call is useful if you have a corrupted
// image that was never fully added to the libpod database.
func (r *Runtime) RemoveImageFromStorage(id string) error {
_, err := r.store.DeleteImage(id, true)
return err
}

func getImageNames(images []*image.Image) string {
var names string
for i := range images {
Expand Down
4 changes: 4 additions & 0 deletions pkg/domain/infra/abi/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,10 @@ func (ir *ImageEngine) Remove(ctx context.Context, images []string, opts entitie
for _, id := range images {
img, err := ir.Libpod.ImageRuntime().NewFromLocal(id)
if err != nil {
// attempt to remove image from storage
if forceErr := ir.Libpod.RemoveImageFromStorage(id); forceErr == nil {
continue
}
rmErrors = append(rmErrors, err)
continue
}
Expand Down

0 comments on commit 021ff99

Please sign in to comment.