Skip to content

Commit

Permalink
Deleting an n use image should return conflict not system error
Browse files Browse the repository at this point in the history
Fixes: containers#14208

Signed-off-by: Daniel J Walsh <[email protected]>
  • Loading branch information
rhatdan committed May 16, 2022
1 parent d8e8e62 commit ee782fc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/api/handlers/compat/images_remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
11 changes: 11 additions & 0 deletions test/apiv2/10-images.at
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ee782fc

Please sign in to comment.