Skip to content

Commit

Permalink
Merge pull request #22715 from rhatdan/volumes1
Browse files Browse the repository at this point in the history
Return StatusNotFound when multiple volumes matching occurs
  • Loading branch information
openshift-merge-bot[bot] authored May 16, 2024
2 parents c4631dc + 6408a05 commit 31bfabf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
16 changes: 11 additions & 5 deletions pkg/api/handlers/utils/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,51 +34,57 @@ func Error(w http.ResponseWriter, code int, err error) {
}

func VolumeNotFound(w http.ResponseWriter, name string, err error) {
if !errors.Is(err, define.ErrNoSuchVolume) {
InternalServerError(w, err)
if errors.Is(err, define.ErrNoSuchVolume) || errors.Is(err, define.ErrVolumeExists) {
Error(w, http.StatusNotFound, err)
return
}
Error(w, http.StatusNotFound, err)
InternalServerError(w, err)
}

func ContainerNotFound(w http.ResponseWriter, name string, err error) {
if errors.Is(err, define.ErrNoSuchCtr) || errors.Is(err, define.ErrCtrExists) {
Error(w, http.StatusNotFound, err)
} else {
InternalServerError(w, err)
return
}
InternalServerError(w, err)
}

func ImageNotFound(w http.ResponseWriter, name string, err error) {
if !errors.Is(err, storage.ErrImageUnknown) {
InternalServerError(w, err)
return
}
Error(w, http.StatusNotFound, err)
}

func NetworkNotFound(w http.ResponseWriter, name string, err error) {
if !errors.Is(err, define.ErrNoSuchNetwork) {
InternalServerError(w, err)
return
}
Error(w, http.StatusNotFound, err)
}

func PodNotFound(w http.ResponseWriter, name string, err error) {
if !errors.Is(err, define.ErrNoSuchPod) {
InternalServerError(w, err)
return
}
Error(w, http.StatusNotFound, err)
}

func SessionNotFound(w http.ResponseWriter, name string, err error) {
if !errors.Is(err, define.ErrNoSuchExecSession) {
InternalServerError(w, err)
return
}
Error(w, http.StatusNotFound, err)
}

func SecretNotFound(w http.ResponseWriter, nameOrID string, err error) {
if errorhandling.Cause(err).Error() != "no such secret" {
InternalServerError(w, err)
return
}
Error(w, http.StatusNotFound, err)
}
Expand Down
4 changes: 0 additions & 4 deletions test/e2e/volume_rm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,6 @@ var _ = Describe("Podman volume rm", func() {
// boltdb issues volume name in quotes
expect = `more than one result for volume name "myv": volume already exists`
}
if IsRemote() {
// FIXME: #22616
expect = `unmarshalling error into &errorhandling.ErrorModel`
}
Expect(session).To(ExitWithError(125, expect))

session = podmanTest.Podman([]string{"volume", "ls"})
Expand Down

1 comment on commit 31bfabf

@packit-as-a-service
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

podman-next COPR build failed. @containers/packit-build please check.

Please sign in to comment.