summaryrefslogtreecommitdiff
path: root/pkg/api/handlers/compat
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2020-11-17 16:41:52 -0500
committerDaniel J Walsh <dwalsh@redhat.com>2020-11-18 12:57:39 -0500
commit72b67715f8c97fce7bde4677eacfa413b1dafb88 (patch)
treecf72dc6e1493cb2e6c5af4a56093bf0adf29ac6c /pkg/api/handlers/compat
parent6ece1d97c428f1641cb35972357cd037562fd06e (diff)
downloadpodman-72b67715f8c97fce7bde4677eacfa413b1dafb88.tar.gz
podman-72b67715f8c97fce7bde4677eacfa413b1dafb88.tar.bz2
podman-72b67715f8c97fce7bde4677eacfa413b1dafb88.zip
podman-remote network rm --force is broken
The --force parameter was not being handled correctly. This is leading to some race conditions in testing failures. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'pkg/api/handlers/compat')
-rw-r--r--pkg/api/handlers/compat/networks.go37
1 files changed, 26 insertions, 11 deletions
diff --git a/pkg/api/handlers/compat/networks.go b/pkg/api/handlers/compat/networks.go
index 64ddebf9c..0158dad51 100644
--- a/pkg/api/handlers/compat/networks.go
+++ b/pkg/api/handlers/compat/networks.go
@@ -289,25 +289,40 @@ func CreateNetwork(w http.ResponseWriter, r *http.Request) {
func RemoveNetwork(w http.ResponseWriter, r *http.Request) {
runtime := r.Context().Value("runtime").(*libpod.Runtime)
- config, err := runtime.GetConfig()
- if err != nil {
- utils.InternalServerError(w, err)
+ ic := abi.ContainerEngine{Libpod: runtime}
+
+ query := struct {
+ Force bool `schema:"force"`
+ }{
+ // This is where you can override the golang default value for one of fields
+ }
+
+ decoder := r.Context().Value("decoder").(*schema.Decoder)
+ if err := decoder.Decode(&query, r.URL.Query()); err != nil {
+ utils.Error(w, "Something went wrong.", http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
return
}
+
+ options := entities.NetworkRmOptions{
+ Force: query.Force,
+ }
+
name := utils.GetName(r)
- exists, err := network.Exists(config, name)
+ reports, err := ic.NetworkRm(r.Context(), []string{name}, options)
if err != nil {
- utils.InternalServerError(w, err)
- return
- }
- if !exists {
- utils.Error(w, "network not found", http.StatusNotFound, define.ErrNoSuchNetwork)
+ utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "remove Network create"))
return
}
- if err := network.RemoveNetwork(config, name); err != nil {
- utils.InternalServerError(w, err)
+ report := reports[0]
+ if report.Err != nil {
+ if errors.Cause(report.Err) == define.ErrNoSuchNetwork {
+ utils.Error(w, "network not found", http.StatusNotFound, define.ErrNoSuchNetwork)
+ return
+ }
+ utils.InternalServerError(w, report.Err)
return
}
+
utils.WriteResponse(w, http.StatusNoContent, "")
}