summaryrefslogtreecommitdiff
path: root/libpod/networking_linux.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2018-11-09 09:41:26 -0800
committerGitHub <noreply@github.com>2018-11-09 09:41:26 -0800
commit7813f90ce623c8882e53171c8ffe7fb46664ead7 (patch)
tree2d2b21638d44a9e00f6cb73b8222aea7c14d8335 /libpod/networking_linux.go
parente8e16fcc789df6a705fbbf5c5597f16a4255d690 (diff)
parent7e15084d1987425c70850353462b0b80269300f9 (diff)
downloadpodman-7813f90ce623c8882e53171c8ffe7fb46664ead7.tar.gz
podman-7813f90ce623c8882e53171c8ffe7fb46664ead7.tar.bz2
podman-7813f90ce623c8882e53171c8ffe7fb46664ead7.zip
Merge pull request #1789 from mheon/fix_add_hosts_test
Accurately update state if prepare() partially fails
Diffstat (limited to 'libpod/networking_linux.go')
-rw-r--r--libpod/networking_linux.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/libpod/networking_linux.go b/libpod/networking_linux.go
index 212485d8a..43d0a61a4 100644
--- a/libpod/networking_linux.go
+++ b/libpod/networking_linux.go
@@ -90,13 +90,16 @@ func (r *Runtime) configureNetNS(ctr *Container, ctrNS ns.NetNS) ([]*cnitypes.Re
}
// Create and configure a new network namespace for a container
-func (r *Runtime) createNetNS(ctr *Container) (ns.NetNS, []*cnitypes.Result, error) {
+func (r *Runtime) createNetNS(ctr *Container) (n ns.NetNS, q []*cnitypes.Result, err error) {
ctrNS, err := netns.NewNS()
if err != nil {
return nil, nil, errors.Wrapf(err, "error creating network namespace for container %s", ctr.ID())
}
defer func() {
if err != nil {
+ if err2 := netns.UnmountNS(ctrNS); err2 != nil {
+ logrus.Errorf("Error unmounting partially created network namespace for container %s: %v", ctr.ID(), err2)
+ }
if err2 := ctrNS.Close(); err2 != nil {
logrus.Errorf("Error closing partially created network namespace for container %s: %v", ctr.ID(), err2)
}