From 1a659bc68ec3a1c7ad2019de9cf82f4c23827cfb Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Fri, 30 Apr 2021 19:12:07 +0900 Subject: [PATCH 1/4] Revert "Makefile: rm go 1.13 workaround" This reverts commit d0cbef576f8bb2ce55ec735999e3f8228da26807. Dockre/Moby still builds runc with Go 1.13, so we should still support Go 1.13. Signed-off-by: Akihiro Suda --- Makefile | 10 +++++++--- README.md | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 56ce52944..1d43f3537 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,10 @@ COMMIT_NO := $(shell git rev-parse HEAD 2> /dev/null || true) COMMIT ?= $(if $(shell git status --porcelain --untracked-files=no),"$(COMMIT_NO)-dirty","$(COMMIT_NO)") VERSION := $(shell cat ./VERSION) +# TODO: rm -mod=vendor once go 1.13 is unsupported +ifneq ($(GO111MODULE),off) + MOD_VENDOR := "-mod=vendor" +endif ifeq ($(shell $(GO) env GOOS),linux) ifeq (,$(filter $(shell $(GO) env GOARCH),mips mipsle mips64 mips64le ppc64)) ifeq (,$(findstring -race,$(EXTRA_FLAGS))) @@ -21,9 +25,9 @@ ifeq ($(shell $(GO) env GOOS),linux) endif endif endif -GO_BUILD := $(GO) build -trimpath $(GO_BUILDMODE) $(EXTRA_FLAGS) -tags "$(BUILDTAGS)" \ +GO_BUILD := $(GO) build -trimpath $(MOD_VENDOR) $(GO_BUILDMODE) $(EXTRA_FLAGS) -tags "$(BUILDTAGS)" \ -ldflags "-X main.gitCommit=$(COMMIT) -X main.version=$(VERSION) $(EXTRA_LDFLAGS)" -GO_BUILD_STATIC := CGO_ENABLED=1 $(GO) build -trimpath $(EXTRA_FLAGS) -tags "$(BUILDTAGS) netgo osusergo" \ +GO_BUILD_STATIC := CGO_ENABLED=1 $(GO) build -trimpath $(MOD_VENDOR) $(EXTRA_FLAGS) -tags "$(BUILDTAGS) netgo osusergo" \ -ldflags "-w -extldflags -static -X main.gitCommit=$(COMMIT) -X main.version=$(VERSION) $(EXTRA_LDFLAGS)" .DEFAULT: runc @@ -70,7 +74,7 @@ unittest: runcimage $(RUNC_IMAGE) make localunittest TESTFLAGS=$(TESTFLAGS) localunittest: all - $(GO) test -timeout 3m -tags "$(BUILDTAGS)" $(TESTFLAGS) -v ./... + $(GO) test $(MOD_VENDOR) -timeout 3m -tags "$(BUILDTAGS)" $(TESTFLAGS) -v ./... integration: runcimage $(CONTAINER_ENGINE) run $(CONTAINER_ENGINE_RUN_FLAGS) \ diff --git a/README.md b/README.md index f978c73ef..23106d303 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ A third party security audit was performed by Cure53, you can see the full repor ## Building `runc` currently supports the Linux platform with various architecture support. -It must be built with Go version 1.14 or higher. +It must be built with Go version 1.13 or higher. In order to enable seccomp support you will need to install `libseccomp` on your platform. > e.g. `libseccomp-devel` for CentOS, or `libseccomp-dev` for Ubuntu From 45f49e8fcab9d993952b8b5fb85a1c13b3e817cb Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Fri, 30 Apr 2021 19:13:05 +0900 Subject: [PATCH 2/4] libcontainer: avoid using t.Cleanup t.Cleanup is not present in Go 1.13. Dockre/Moby still builds runc with Go 1.13, so we should still support Go 1.13. Signed-off-by: Akihiro Suda --- libcontainer/logs/logs_linux_test.go | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/libcontainer/logs/logs_linux_test.go b/libcontainer/logs/logs_linux_test.go index 7e2b59d9c..89912c464 100644 --- a/libcontainer/logs/logs_linux_test.go +++ b/libcontainer/logs/logs_linux_test.go @@ -13,6 +13,7 @@ import ( func TestLoggingToFile(t *testing.T) { l := runLogForwarding(t) + defer l.cleanup() logToLogWriter(t, l, `{"level": "info","msg":"kitten"}`) finish(t, l) @@ -21,6 +22,7 @@ func TestLoggingToFile(t *testing.T) { func TestLogForwardingDoesNotStopOnJsonDecodeErr(t *testing.T) { l := runLogForwarding(t) + defer l.cleanup() logToLogWriter(t, l, "invalid-json-with-kitten") checkWait(t, l, "failed to decode") @@ -34,6 +36,7 @@ func TestLogForwardingDoesNotStopOnJsonDecodeErr(t *testing.T) { func TestLogForwardingDoesNotStopOnLogLevelParsingErr(t *testing.T) { l := runLogForwarding(t) + defer l.cleanup() logToLogWriter(t, l, `{"level": "alert","msg":"puppy"}`) checkWait(t, l, "failed to parse log level") @@ -47,6 +50,7 @@ func TestLogForwardingDoesNotStopOnLogLevelParsingErr(t *testing.T) { func TestLogForwardingStopsAfterClosingTheWriter(t *testing.T) { l := runLogForwarding(t) + defer l.cleanup() logToLogWriter(t, l, `{"level": "info","msg":"sync"}`) @@ -73,6 +77,9 @@ type log struct { w io.WriteCloser file string done chan error + + // TODO: use t.Cleanup after dropping support for Go 1.13 + cleanup func() } func runLogForwarding(t *testing.T) *log { @@ -81,10 +88,6 @@ func runLogForwarding(t *testing.T) *log { if err != nil { t.Fatal(err) } - t.Cleanup(func() { - logR.Close() - logW.Close() - }) tempFile, err := ioutil.TempFile("", "") if err != nil { @@ -92,7 +95,6 @@ func runLogForwarding(t *testing.T) *log { } tempFile.Close() logFile := tempFile.Name() - t.Cleanup(func() { os.Remove(logFile) }) logConfig := Config{LogLevel: logrus.InfoLevel, LogFormat: "json", LogFilePath: logFile} loggingConfigured = false @@ -102,7 +104,13 @@ func runLogForwarding(t *testing.T) *log { doneForwarding := ForwardLogs(logR) - return &log{w: logW, done: doneForwarding, file: logFile} + cleanup := func() { + os.Remove(logFile) + logR.Close() + logW.Close() + } + + return &log{w: logW, done: doneForwarding, file: logFile, cleanup: cleanup} } func finish(t *testing.T, l *log) { From e2dd9220ddfa3fd15e359cfcf8638a059f3c4ae9 Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Fri, 30 Apr 2021 19:15:18 +0900 Subject: [PATCH 3/4] go.mod: demote to Go 1.13 Dockre/Moby still builds runc with Go 1.13, so we should still support Go 1.13. Signed-off-by: Akihiro Suda --- go.mod | 2 +- vendor/modules.txt | 21 --------------------- 2 files changed, 1 insertion(+), 22 deletions(-) diff --git a/go.mod b/go.mod index 07d6260af..105cec579 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/opencontainers/runc -go 1.14 +go 1.13 require ( github.com/checkpoint-restore/go-criu/v5 v5.0.0 diff --git a/vendor/modules.txt b/vendor/modules.txt index 792a957b6..dac28f3ac 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,9 +1,7 @@ # github.com/checkpoint-restore/go-criu/v5 v5.0.0 -## explicit github.com/checkpoint-restore/go-criu/v5 github.com/checkpoint-restore/go-criu/v5/rpc # github.com/cilium/ebpf v0.5.0 -## explicit github.com/cilium/ebpf github.com/cilium/ebpf/asm github.com/cilium/ebpf/internal @@ -11,78 +9,59 @@ github.com/cilium/ebpf/internal/btf github.com/cilium/ebpf/internal/unix github.com/cilium/ebpf/link # github.com/containerd/console v1.0.2 -## explicit github.com/containerd/console # github.com/coreos/go-systemd/v22 v22.3.1 -## explicit github.com/coreos/go-systemd/v22/activation github.com/coreos/go-systemd/v22/dbus # github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d github.com/cpuguy83/go-md2man/v2/md2man # github.com/cyphar/filepath-securejoin v0.2.2 -## explicit github.com/cyphar/filepath-securejoin # github.com/docker/go-units v0.4.0 -## explicit github.com/docker/go-units # github.com/godbus/dbus/v5 v5.0.4 -## explicit github.com/godbus/dbus/v5 # github.com/golang/protobuf v1.4.3 github.com/golang/protobuf/proto # github.com/moby/sys/mountinfo v0.4.1 -## explicit github.com/moby/sys/mountinfo # github.com/mrunalp/fileutils v0.5.0 -## explicit github.com/mrunalp/fileutils # github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417 -## explicit github.com/opencontainers/runtime-spec/specs-go # github.com/opencontainers/selinux v1.8.0 -## explicit github.com/opencontainers/selinux/go-selinux github.com/opencontainers/selinux/go-selinux/label github.com/opencontainers/selinux/pkg/pwalk # github.com/pkg/errors v0.9.1 -## explicit github.com/pkg/errors # github.com/russross/blackfriday/v2 v2.0.1 github.com/russross/blackfriday/v2 # github.com/seccomp/libseccomp-golang v0.9.1 -## explicit github.com/seccomp/libseccomp-golang # github.com/shurcooL/sanitized_anchor_name v1.0.0 github.com/shurcooL/sanitized_anchor_name # github.com/sirupsen/logrus v1.7.0 -## explicit github.com/sirupsen/logrus github.com/sirupsen/logrus/hooks/test # github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 -## explicit github.com/syndtr/gocapability/capability # github.com/urfave/cli v1.22.1 -## explicit github.com/urfave/cli # github.com/vishvananda/netlink v1.1.0 -## explicit github.com/vishvananda/netlink github.com/vishvananda/netlink/nl # github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df github.com/vishvananda/netns # github.com/willf/bitset v1.1.11 -## explicit github.com/willf/bitset # golang.org/x/net v0.0.0-20201224014010-6772e930b67b -## explicit golang.org/x/net/bpf # golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c -## explicit golang.org/x/sys/internal/unsafeheader golang.org/x/sys/unix golang.org/x/sys/windows # google.golang.org/protobuf v1.25.0 -## explicit google.golang.org/protobuf/encoding/prototext google.golang.org/protobuf/encoding/protowire google.golang.org/protobuf/internal/descfmt From ee4612bcdcc67b19a299f56dc53bf24b85da3110 Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Fri, 30 Apr 2021 19:15:51 +0900 Subject: [PATCH 4/4] CI: enable Go 1.13 again Dockre/Moby still builds runc with Go 1.13, so we should still support Go 1.13. Signed-off-by: Akihiro Suda --- .github/workflows/test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0aa834e63..f125887cd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,7 +19,8 @@ jobs: strategy: fail-fast: false matrix: - go-version: [1.14.x, 1.15.x, 1.16.x] + # Dockre/Moby still builds runc with Go 1.13, so we should still support Go 1.13. + go-version: [1.13.x, 1.15.x, 1.16.x] rootless: ["rootless", ""] race: ["-race", ""]