golang.org/x/sys now requires go1.17 as a minimum, and otherwise
fails:
Error: ../../../go/pkg/mod/golang.org/x/sys@v0.2.0/unix/syscall.go:83:16: undefined: unsafe.Slice
Error: ../../../go/pkg/mod/golang.org/x/sys@v0.2.0/unix/syscall_linux.go:2256:9: undefined: unsafe.Slice
Error: ../../../go/pkg/mod/golang.org/x/sys@v0.2.0/unix/syscall_unix.go:118:7: undefined: unsafe.Slice
Error: ../../../go/pkg/mod/golang.org/x/sys@v0.2.0/unix/sysvshm_unix.go:33:7: undefined: unsafe.Slice
unsafe.Slice was added in go1.17; https://pkg.go.dev/unsafe#Slice
Now that go1.17 is the minimum version, we cal also replace the deprecated io/ioutil
package (which was deprecated in go1.16).
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
The GetFromName() function looked for network namespaces in "/var/run",
whereas DeleteNamed() and NewNamed() used the "bindMountPath" const (which
points to "/run/netns"). While "/var/run" should be symlink to "/run" on
most distros, this is not a guarantee, so use the same paths so that at
least the code is consistently using this path.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
The bindMountPath const was in the same group as the deprecated consts,
which were deprecated as a whole. This patch moves the bindMountPath
const outside of the group to make sure it's not considered deprecated.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
The consts were deprecated in favor of their counterparts in
golang.org/x/sys/unix. This patch makes them an alias / sets them
to those values, which makes it more transparent that they're the
same.
Also update internal uses of the deprecated consts, as they
should no longer be used, and updated the "stub" function
to be deprecated as well.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
- NSHandle could only be used on Unix systems. Given that all other parts
of the code are only implemented on Linux (not for other Unix-y platforms),
I moved this file to be Linux-only.
- Rename "_unspecified" to "_others", which is a common suffix for such cases.
- Introduce stubs for NSHandle for non-Linux platforms.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
These tests were testing functionality that was only supported on
Linux, but stubbed for other platforms, so move them to a linux-only
file.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
- The "linux" build tags were redundant as they were in a _linux file
- The project already states that go1.10 is a minimum (and long obsolete,
so unlikely to be used still).
- Format the remaining build-tags for current go versions.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
The syscall package is deprecated and no longer updated as per
https://golang.org/pkg/syscall/. Use the golang.org/x/sys/unix package
instead, which also provides a wrapper for SYS_SETNS, so the syscall
number encoding depending on runtime.GOARCH can be dropped.
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Remove from the README.md example the instruction which explicitly sets
the newly created netns as the netns of the current OS Thread. The removed
instruction is not needed because the setting is implicitly done by netns.New().
This prevents netns from being used on older Go runtimes on which it's
not safe to perform any state manipulations of a scheduling thread
(https://github.com/golang/go/issues/20676).
Signed-off-by: Martynas Pumputis <m@lambda.lt>
When using Kubernetes with CNI and Docker, the cgroup entries are
dropped in yet another creative place. This adds yet another attempt
to locate the container within `kubepods`. All of this because there
are no named network namespaces created.
With ubuntu 16.04 and docker-engine 1.11, the docker netns detection
function failed to look for the correct location of task file. This
change fixed the issue.
Signed-off-by: Zhenfang Wei <kopkop@gmail.com>