summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2018-12-17 10:57:56 -0800
committerGitHub <noreply@github.com>2018-12-17 10:57:56 -0800
commitc588c31cdb9ac5e2dcdded92603ed63ca19f674a (patch)
tree7eb1317a41f59ca07f240860e6624dca47d62305 /cmd/podman
parent510b5a81dcea7df4c95388db0b66df17a691cb1c (diff)
parentf020f3146d33ab68c557cbbec5d6a1be7ad15f7f (diff)
downloadpodman-c588c31cdb9ac5e2dcdded92603ed63ca19f674a.tar.gz
podman-c588c31cdb9ac5e2dcdded92603ed63ca19f674a.tar.bz2
podman-c588c31cdb9ac5e2dcdded92603ed63ca19f674a.zip
Merge pull request #2018 from baude/rmiinfra
display proper error when rmi -fa with infra containers
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/rmi.go25
1 files changed, 19 insertions, 6 deletions
diff --git a/cmd/podman/rmi.go b/cmd/podman/rmi.go
index 0f4f8765b..910c7ba35 100644
--- a/cmd/podman/rmi.go
+++ b/cmd/podman/rmi.go
@@ -46,6 +46,13 @@ var (
)
func rmiCmd(c *cli.Context) error {
+ var (
+ lastError error
+ deleted bool
+ deleteErr error
+ msg string
+ )
+
ctx := getContext()
if err := validateFlags(c, rmiFlags); err != nil {
return err
@@ -66,20 +73,18 @@ func rmiCmd(c *cli.Context) error {
}
images := args[:]
- var lastError error
- var deleted bool
removeImage := func(img *image.Image) {
deleted = true
- msg, err := runtime.RemoveImage(ctx, img, c.Bool("force"))
- if err != nil {
- if errors.Cause(err) == storage.ErrImageUsedByContainer {
+ msg, deleteErr = runtime.RemoveImage(ctx, img, c.Bool("force"))
+ if deleteErr != nil {
+ if errors.Cause(deleteErr) == storage.ErrImageUsedByContainer {
fmt.Printf("A container associated with containers/storage, i.e. via Buildah, CRI-O, etc., may be associated with this image: %-12.12s\n", img.ID())
}
if lastError != nil {
fmt.Fprintln(os.Stderr, lastError)
}
- lastError = err
+ lastError = deleteErr
} else {
fmt.Println(msg)
}
@@ -108,6 +113,14 @@ func rmiCmd(c *cli.Context) error {
}
lastNumberofImages = len(imagesToDelete)
imagesToDelete, err = runtime.ImageRuntime().GetImages()
+ if err != nil {
+ return err
+ }
+ // If no images are left to delete or there is just one image left and it cannot be deleted,
+ // lets break out and display the error
+ if len(imagesToDelete) == 0 || (lastNumberofImages == 1 && lastError != nil) {
+ break
+ }
}
} else {
// Create image.image objects for deletion from user input.