From 370a9ed6e93c33d4eecd3c7bd81b51708b73336b Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 6 Aug 2024 13:08:22 +0200 Subject: [PATCH] user: move userns package to separate module, and retract v0.2.0 commit 86870e7b5ae771ec567bf0519663b95345ba59e3 integrated the userns package into the github.com/moby/sys/user module, which was included in the v0.2.0 version of the module. Upon further discussion with maintainers, this may not have been a good choice; the userns package is related to user-namespaces (uid/gid-mapping), and while there are some tangential relations with "user", we shouldn't conflate these concepts by putting both into the same module. Some downstream projects (containerd, moby, containerd/cgroups) already accepted patches to switch to the package that's part of the moby/sys/user module, but none of those patches made it into a release. This patch: - moves the userns package to a separate module - retracts the moby/sys/user v0.2.0 release - downgrades the minimum go version update for the moby/sys/user module to go1.17. Note that CI is no longer testing go1.17, but go1.18 as minimum. Signed-off-by: Sebastiaan van Stijn --- .github/workflows/test.yml | 5 +++++ Makefile | 18 ++++++------------ user/go.mod | 4 +++- userns/go.mod | 3 +++ {user/userns => userns}/userns.go | 0 {user/userns => userns}/userns_linux.go | 0 {user/userns => userns}/userns_linux_fuzzer.go | 0 {user/userns => userns}/userns_linux_test.go | 0 {user/userns => userns}/userns_unsupported.go | 0 9 files changed, 17 insertions(+), 13 deletions(-) create mode 100644 userns/go.mod rename {user/userns => userns}/userns.go (100%) rename {user/userns => userns}/userns_linux.go (100%) rename {user/userns => userns}/userns_linux_fuzzer.go (100%) rename {user/userns => userns}/userns_linux_test.go (100%) rename {user/userns => userns}/userns_unsupported.go (100%) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5a73adf..574a913 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,6 +14,11 @@ jobs: go-version: ${{ matrix.go-version }} - name: Checkout code uses: actions/checkout@v4 + - if: ${{ matrix.go-version == '1.18.x' }} + run: | + # This corresponds with the list in Makefile:1, but omits the "userns" + # module, which requires go1.21 as minimum. + echo 'PACKAGES="mountinfo mount sequential signal symlink user"' >> $GITHUB_ENV - name: go mod tidy run: | make tidy diff --git a/Makefile b/Makefile index c83bf16..ef839af 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -PACKAGES ?= mountinfo mount sequential signal symlink user +PACKAGES ?= mountinfo mount sequential signal symlink user userns # IMPORTANT: when updating this list, also update the conditional one in .github/workflows/test.yml BINDIR ?= _build/bin CROSS ?= linux/arm linux/arm64 linux/ppc64le linux/s390x \ freebsd/amd64 openbsd/amd64 darwin/amd64 darwin/arm64 windows/amd64 @@ -16,18 +16,14 @@ clean: test: test-local set -eu; \ for p in $(PACKAGES); do \ - if $p = user && go version | grep -qv go1.18; then \ - (cd $$p; go test $(RUN_VIA_SUDO) -v .); \ - fi \ + (cd $$p; go test $(RUN_VIA_SUDO) -v .); \ done .PHONY: tidy tidy: set -eu; \ for p in $(PACKAGES); do \ - if $p = user && go version | grep -qv go1.18; then \ - (cd $$p; go mod tidy); \ - fi \ + (cd $$p; go mod tidy); \ done # Test the mount module against the local mountinfo source code instead of the @@ -46,11 +42,9 @@ lint: $(BINDIR)/golangci-lint $(BINDIR)/golangci-lint version set -eu; \ for p in $(PACKAGES); do \ - if $p = user && go version | grep -qv go1.18; then \ - (cd $$p; \ - go mod download; \ - ../$(BINDIR)/golangci-lint run); \ - fi \ + (cd $$p; \ + go mod download; \ + ../$(BINDIR)/golangci-lint run); \ done $(BINDIR)/golangci-lint: $(BINDIR) diff --git a/user/go.mod b/user/go.mod index d4ad72f..bf7886e 100644 --- a/user/go.mod +++ b/user/go.mod @@ -1,5 +1,7 @@ module github.com/moby/sys/user -go 1.21 +go 1.17 require golang.org/x/sys v0.1.0 + +retract v0.2.0 // Package github.com/moby/sys/user/userns was included in this module, but should've been a separate module; see https://github.com/moby/sys/pull/140#issuecomment-2250644304. diff --git a/userns/go.mod b/userns/go.mod new file mode 100644 index 0000000..1b656e4 --- /dev/null +++ b/userns/go.mod @@ -0,0 +1,3 @@ +module github.com/moby/sys/userns + +go 1.21 diff --git a/user/userns/userns.go b/userns/userns.go similarity index 100% rename from user/userns/userns.go rename to userns/userns.go diff --git a/user/userns/userns_linux.go b/userns/userns_linux.go similarity index 100% rename from user/userns/userns_linux.go rename to userns/userns_linux.go diff --git a/user/userns/userns_linux_fuzzer.go b/userns/userns_linux_fuzzer.go similarity index 100% rename from user/userns/userns_linux_fuzzer.go rename to userns/userns_linux_fuzzer.go diff --git a/user/userns/userns_linux_test.go b/userns/userns_linux_test.go similarity index 100% rename from user/userns/userns_linux_test.go rename to userns/userns_linux_test.go diff --git a/user/userns/userns_unsupported.go b/userns/userns_unsupported.go similarity index 100% rename from user/userns/userns_unsupported.go rename to userns/userns_unsupported.go