diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-03-10 14:04:51 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-10 14:04:51 +0100 |
commit | 786757fb01208cf72e1c67611acbab1411746036 (patch) | |
tree | bf5913f1abfc434f5dc3a2fb7684c7dc416aa296 /pkg | |
parent | 5331096b3882cd5c8e587200560e44ef1eb990a3 (diff) | |
parent | f1eb8e816257d9dc810cfa6957e09db1ffa7db96 (diff) | |
download | podman-786757fb01208cf72e1c67611acbab1411746036.tar.gz podman-786757fb01208cf72e1c67611acbab1411746036.tar.bz2 podman-786757fb01208cf72e1c67611acbab1411746036.zip |
Merge pull request #9681 from rhatdan/rm
Removing a non existing container API should return 404
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/api/handlers/compat/containers.go | 7 | ||||
-rw-r--r-- | pkg/domain/infra/abi/containers.go | 4 |
2 files changed, 8 insertions, 3 deletions
diff --git a/pkg/api/handlers/compat/containers.go b/pkg/api/handlers/compat/containers.go index d26bb50f4..d3277b815 100644 --- a/pkg/api/handlers/compat/containers.go +++ b/pkg/api/handlers/compat/containers.go @@ -76,7 +76,12 @@ func RemoveContainer(w http.ResponseWriter, r *http.Request) { return } if len(report) > 0 && report[0].Err != nil { - utils.InternalServerError(w, report[0].Err) + err = report[0].Err + if errors.Cause(err) == define.ErrNoSuchCtr { + utils.ContainerNotFound(w, name, err) + return + } + utils.InternalServerError(w, err) return } diff --git a/pkg/domain/infra/abi/containers.go b/pkg/domain/infra/abi/containers.go index 4790bd58c..637531ee9 100644 --- a/pkg/domain/infra/abi/containers.go +++ b/pkg/domain/infra/abi/containers.go @@ -301,14 +301,14 @@ func (ic *ContainerEngine) ContainerRm(ctx context.Context, namesOrIds []string, for _, ctr := range names { logrus.Debugf("Evicting container %q", ctr) report := entities.RmReport{Id: ctr} - id, err := ic.Libpod.EvictContainer(ctx, ctr, options.Volumes) + _, err := ic.Libpod.EvictContainer(ctx, ctr, options.Volumes) if err != nil { if options.Ignore && errors.Cause(err) == define.ErrNoSuchCtr { logrus.Debugf("Ignoring error (--allow-missing): %v", err) reports = append(reports, &report) continue } - report.Err = errors.Wrapf(err, "failed to evict container: %q", id) + report.Err = err reports = append(reports, &report) continue } |