summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2022-05-12 17:00:44 -0400
committerMatthew Heon <mheon@redhat.com>2022-06-14 13:45:54 -0400
commit74ac2dda297eb315254e805c9a5c9b6a7c3eda89 (patch)
treeed97030768cc8b885f70288a3fb015fdee2a596b
parent5549495f4ebb0c971c61ebae67d2aa6079213901 (diff)
downloadpodman-74ac2dda297eb315254e805c9a5c9b6a7c3eda89.tar.gz
podman-74ac2dda297eb315254e805c9a5c9b6a7c3eda89.tar.bz2
podman-74ac2dda297eb315254e805c9a5c9b6a7c3eda89.zip
Deleting an n use image should return conflict not system error
Fixes: https://github.com/containers/podman/issues/14208 Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
-rw-r--r--pkg/api/handlers/compat/images_remove.go5
-rw-r--r--test/apiv2/10-images.at11
2 files changed, 15 insertions, 1 deletions
diff --git a/pkg/api/handlers/compat/images_remove.go b/pkg/api/handlers/compat/images_remove.go
index f45b38c66..35bcb36aa 100644
--- a/pkg/api/handlers/compat/images_remove.go
+++ b/pkg/api/handlers/compat/images_remove.go
@@ -52,7 +52,10 @@ func RemoveImage(w http.ResponseWriter, r *http.Request) {
utils.ImageNotFound(w, name, errors.Wrapf(err, "failed to find image %s", name))
return
}
-
+ if errors.Cause(err) == storage.ErrImageUsedByContainer {
+ utils.Error(w, http.StatusConflict, errors.Wrapf(err, "image %s is in use", name))
+ return
+ }
utils.Error(w, http.StatusInternalServerError, err)
return
}
diff --git a/test/apiv2/10-images.at b/test/apiv2/10-images.at
index 9526183e3..b5305537d 100644
--- a/test/apiv2/10-images.at
+++ b/test/apiv2/10-images.at
@@ -156,6 +156,17 @@ t GET images/json?filters='{"reference":["test1"]}' 200 length=1
t DELETE libpod/images/test1:latest 200
+# to be used in prune until filter tests
+podman image build -t docker.io/library/test1:latest -<<EOF
+from alpine
+RUN >file4
+EOF
+podman create --name test1 test1 echo hi
+
+t DELETE images/test1:latest 409
+podman rm test1
+t DELETE images/test1:latest 200
+
t GET "images/get?names=alpine" 200 '[POSIX tar archive]'
podman pull busybox