diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-07-11 21:35:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-11 21:35:45 +0200 |
commit | d614372c2f39cea32641ec92c84a9e48657cfb41 (patch) | |
tree | 032338943b478c70e6ded7c103cea0311481cca8 /pkg/netns | |
parent | 2b64f8844655b7188332a404ec85d32c33feb9e9 (diff) | |
parent | a78c885397ad2938b9b21438bcfa8a00dd1eb03f (diff) | |
download | podman-d614372c2f39cea32641ec92c84a9e48657cfb41.tar.gz podman-d614372c2f39cea32641ec92c84a9e48657cfb41.tar.bz2 podman-d614372c2f39cea32641ec92c84a9e48657cfb41.zip |
Merge pull request #3552 from baude/golangcilint2
golangci-lint pass number 2
Diffstat (limited to 'pkg/netns')
-rw-r--r-- | pkg/netns/netns_linux.go | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/pkg/netns/netns_linux.go b/pkg/netns/netns_linux.go index 4a515c72a..1d6fb873c 100644 --- a/pkg/netns/netns_linux.go +++ b/pkg/netns/netns_linux.go @@ -28,6 +28,7 @@ import ( "sync" "github.com/containernetworking/plugins/pkg/ns" + "github.com/sirupsen/logrus" "golang.org/x/sys/unix" ) @@ -90,7 +91,9 @@ func NewNS() (ns.NetNS, error) { // Ensure the mount point is cleaned up on errors; if the namespace // was successfully mounted this will have no effect because the file // is in-use - defer os.RemoveAll(nsPath) + defer func() { + _ = os.RemoveAll(nsPath) + }() var wg sync.WaitGroup wg.Add(1) @@ -109,7 +112,11 @@ func NewNS() (ns.NetNS, error) { if err != nil { return } - defer origNS.Close() + defer func() { + if err := origNS.Close(); err != nil { + logrus.Errorf("unable to close namespace: %q", err) + } + }() // create a new netns on the current thread err = unix.Unshare(unix.CLONE_NEWNET) @@ -118,7 +125,11 @@ func NewNS() (ns.NetNS, error) { } // Put this thread back to the orig ns, since it might get reused (pre go1.10) - defer origNS.Set() + defer func() { + if err := origNS.Set(); err != nil { + logrus.Errorf("unable to set namespace: %q", err) + } + }() // bind mount the netns from the current thread (from /proc) onto the // mount point. This causes the namespace to persist, even when there |