Skip to content

Commit

Permalink
pkg/netns: remove old pre go 1.10 workaround
Browse files Browse the repository at this point in the history
Because we do not not unlock the OS thread it will be killed by the
runtime and not be reused for go 1.10+. Therefore there is no point in
joining the original netns back which never worked as rootless.

Go 1.10 is EOL for years and our code doesn't compile on such old
versions anyway so it is safe to remove.

Signed-off-by: Paul Holzinger <[email protected]>
  • Loading branch information
Luap99 committed Mar 27, 2023
1 parent 0d468ab commit 40361b5
Showing 1 changed file with 0 additions and 12 deletions.
12 changes: 0 additions & 12 deletions pkg/netns/netns_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,18 +161,6 @@ func NewNSWithName(name string) (ns.NetNS, error) {
return
}

// Put this thread back to the orig ns, since it might get reused (pre go1.10)
defer func() {
if err := origNS.Set(); err != nil {
if unshare.IsRootless() && strings.Contains(err.Error(), "operation not permitted") {
// When running in rootless mode it will fail to re-join
// the network namespace owned by root on the host.
return
}
logrus.Warnf("Unable to reset 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
// are no threads in the ns. Make this a shared mount; it needs to be
Expand Down

0 comments on commit 40361b5

Please sign in to comment.