diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-08-03 09:13:40 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-03 09:13:40 -0400 |
commit | 96ece0ca56fca249bcf84061de0e944f3c092ea5 (patch) | |
tree | c6f1f28ae3481f6b617f5931da9d91f323de556d /pkg/network | |
parent | de5eb3831190262169eab36e64c41992dc22766a (diff) | |
parent | 45b100d21ce1ca1843e26366466d09eac2d4add0 (diff) | |
download | podman-96ece0ca56fca249bcf84061de0e944f3c092ea5.tar.gz podman-96ece0ca56fca249bcf84061de0e944f3c092ea5.tar.bz2 podman-96ece0ca56fca249bcf84061de0e944f3c092ea5.zip |
Merge pull request #7188 from zhangguanzhang/network-404
API returns 500 in case network is not found instead of 404
Diffstat (limited to 'pkg/network')
-rw-r--r-- | pkg/network/config.go | 5 | ||||
-rw-r--r-- | pkg/network/files.go | 3 | ||||
-rw-r--r-- | pkg/network/network.go | 3 |
3 files changed, 4 insertions, 7 deletions
diff --git a/pkg/network/config.go b/pkg/network/config.go index a504e0ad0..0115433e1 100644 --- a/pkg/network/config.go +++ b/pkg/network/config.go @@ -2,7 +2,6 @@ package network import ( "encoding/json" - "errors" "net" ) @@ -20,10 +19,6 @@ const ( DefaultPodmanDomainName = "dns.podman" ) -var ( - ErrNetworkNotFound = errors.New("network not found") -) - // GetDefaultPodmanNetwork outputs the default network for podman func GetDefaultPodmanNetwork() (*net.IPNet, error) { _, n, err := net.ParseCIDR("10.88.1.0/24") diff --git a/pkg/network/files.go b/pkg/network/files.go index beb3289f3..38ce38b97 100644 --- a/pkg/network/files.go +++ b/pkg/network/files.go @@ -10,6 +10,7 @@ import ( "github.com/containernetworking/cni/libcni" "github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator" "github.com/containers/common/pkg/config" + "github.com/containers/podman/v2/libpod/define" "github.com/pkg/errors" ) @@ -55,7 +56,7 @@ func GetCNIConfigPathByName(config *config.Config, name string) (string, error) return confFile, nil } } - return "", errors.Wrap(ErrNetworkNotFound, fmt.Sprintf("unable to find network configuration for %s", name)) + return "", errors.Wrap(define.ErrNoSuchNetwork, fmt.Sprintf("unable to find network configuration for %s", name)) } // ReadRawCNIConfByName reads the raw CNI configuration for a CNI diff --git a/pkg/network/network.go b/pkg/network/network.go index 6c84c8a8a..b24c72f5f 100644 --- a/pkg/network/network.go +++ b/pkg/network/network.go @@ -8,6 +8,7 @@ import ( "github.com/containernetworking/cni/pkg/types" "github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator" "github.com/containers/common/pkg/config" + "github.com/containers/podman/v2/libpod/define" "github.com/containers/podman/v2/pkg/util" "github.com/pkg/errors" "github.com/sirupsen/logrus" @@ -200,7 +201,7 @@ func InspectNetwork(config *config.Config, name string) (map[string]interface{}, func Exists(config *config.Config, name string) (bool, error) { _, err := ReadRawCNIConfByName(config, name) if err != nil { - if errors.Cause(err) == ErrNetworkNotFound { + if errors.Cause(err) == define.ErrNoSuchNetwork { return false, nil } return false, err |