aboutsummaryrefslogtreecommitdiff
path: root/pkg/netns
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2019-07-10 13:14:17 -0500
committerbaude <bbaude@redhat.com>2019-07-11 09:13:06 -0500
commita78c885397ad2938b9b21438bcfa8a00dd1eb03f (patch)
treed02607bb19379942b5cac3aa50e1c7428d68e8b9 /pkg/netns
parente2e8477f83f717d6a92badd317ae909cf185d04e (diff)
downloadpodman-a78c885397ad2938b9b21438bcfa8a00dd1eb03f.tar.gz
podman-a78c885397ad2938b9b21438bcfa8a00dd1eb03f.tar.bz2
podman-a78c885397ad2938b9b21438bcfa8a00dd1eb03f.zip
golangci-lint pass number 2
clean up and prepare to migrate to the golangci-linter Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'pkg/netns')
-rw-r--r--pkg/netns/netns_linux.go17
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