Repository: opencontainers/runc
Pull request #3472 (2022-05-11 23:27:56)

[1.1] Make CI green again
This is a backport of

* #3471
* #3400
* #3370
* #3326 (partial, only commit 907aefd43cd91d4452ca79f0aea8b6ae594c6e95)

to release-1.1 branch, fixing broken CI. See original PRs for description.


Patch:
diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml
index 7194c645..27481118 100644
--- a/.github/workflows/validate.yml
+++ b/.github/workflows/validate.yml
@@ -7,21 +7,25 @@ on:
       - master
       - release-*
   pull_request:
+env:
+  GO_VERSION: 1.17.x
 
 jobs:
 
   lint:
     runs-on: ubuntu-20.04
     steps:
-      - uses: actions/checkout@v2
+      - uses: actions/checkout@v3
+      - uses: actions/setup-go@v2
+        with:
+          go-version: "${{ env.GO_VERSION }}"
       - name: install deps
         run: |
           sudo apt -q update
           sudo apt -q install libseccomp-dev
-      - uses: golangci/golangci-lint-action@v2
+      - uses: golangci/golangci-lint-action@v3
         with:
-          # must be specified without patch version
-          version: v1.42
+          version: v1.44
 
   lint-extra:
     # Extra linters, only checking new code from pull requests.
@@ -30,17 +34,19 @@ jobs:
     permissions:
       contents: read
     steps:
-      - uses: actions/checkout@v2
+      - uses: actions/checkout@v3
+      - uses: actions/setup-go@v2
+        with:
+          go-version: "${{ env.GO_VERSION }}"
       - name: install deps
         run: |
           sudo apt -q update
           sudo apt -q install libseccomp-dev
-      - uses: golangci/golangci-lint-action@v2
+      - uses: golangci/golangci-lint-action@v3
         with:
           only-new-issues: true
           args: --config .golangci-extra.yml
-          # must be specified without patch version
-          version: v1.43
+          version: v1.44
 
 
   compile-buildtags:
@@ -49,18 +55,18 @@ jobs:
       # Don't ignore C warnings. Note that the output of "go env CGO_CFLAGS" by default is "-g -O2", so we keep them.
       CGO_CFLAGS: -g -O2 -Werror
     steps:
-      - uses: actions/checkout@v2
+      - uses: actions/checkout@v3
       - name: install go
         uses: actions/setup-go@v2
         with:
-          go-version: 1.x # Latest stable
+          go-version: "${{ env.GO_VERSION }}"
       - name: compile with no build tags
         run: make BUILDTAGS=""
 
   codespell:
     runs-on: ubuntu-20.04
     steps:
-    - uses: actions/checkout@v2
+    - uses: actions/checkout@v3
     - name: install deps
       # Version of codespell bundled with Ubuntu is way old, so use pip.
       run: pip install codespell
@@ -70,7 +76,7 @@ jobs:
   shfmt:
     runs-on: ubuntu-20.04
     steps:
-    - uses: actions/checkout@v2
+    - uses: actions/checkout@v3
     - name: vars
       run: |
         echo "VERSION=3.3.1" >> $GITHUB_ENV
@@ -93,7 +99,7 @@ jobs:
   shellcheck:
     runs-on: ubuntu-20.04
     steps:
-      - uses: actions/checkout@v2
+      - uses: actions/checkout@v3
       - name: vars
         run: |
           echo 'VERSION=v0.7.2' >> $GITHUB_ENV
@@ -116,11 +122,11 @@ jobs:
   deps:
     runs-on: ubuntu-20.04
     steps:
-    - uses: actions/checkout@v2
+    - uses: actions/checkout@v3
     - name: install go
       uses: actions/setup-go@v2
       with:
-        go-version: 1.x # Latest stable
+        go-version: "${{ env.GO_VERSION }}"
     - name: cache go mod and $GOCACHE
       uses: actions/cache@v2
       with:
@@ -156,7 +162,7 @@ jobs:
     runs-on: ubuntu-20.04
     steps:
     - name: checkout
-      uses: actions/checkout@v2
+      uses: actions/checkout@v3
       with:
         fetch-depth: 0
     - name: install deps
@@ -173,7 +179,7 @@ jobs:
     runs-on: ubuntu-20.04
     steps:
     - name: checkout
-      uses: actions/checkout@v2
+      uses: actions/checkout@v3
       with:
         fetch-depth: 0
       # We have to run this under Docker as Ubuntu (host) does not support all
diff --git a/Vagrantfile.fedora b/Vagrantfile.fedora
index fc96d7f2..b84bd10f 100644
--- a/Vagrantfile.fedora
+++ b/Vagrantfile.fedora
@@ -29,6 +29,9 @@ EOF
     done
     dnf clean all
 
+    # Prevent the "fatal: unsafe repository" git complain during build.
+    git config --global --add safe.directory /vagrant
+
     # Add a user for rootless tests
     useradd -u2000 -m -d/home/rootless -s/bin/bash rootless
 
diff --git a/libcontainer/factory_linux.go b/libcontainer/factory_linux.go
index 023d623f..e6c71ac3 100644
--- a/libcontainer/factory_linux.go
+++ b/libcontainer/factory_linux.go
@@ -338,7 +338,12 @@ func (l *LinuxFactory) StartInitialization() (err error) {
 
 	defer func() {
 		if e := recover(); e != nil {
-			err = fmt.Errorf("panic from initialization: %w, %v", e, string(debug.Stack()))
+			if e, ok := e.(error); ok {
+				err = fmt.Errorf("panic from initialization: %w, %s", e, debug.Stack())
+			} else {
+				//nolint:errorlint // here e is not of error type
+				err = fmt.Errorf("panic from initialization: %v, %s", e, debug.Stack())
+			}
 		}
 	}()
 
diff --git a/libcontainer/process_linux.go b/libcontainer/process_linux.go
index e025445d..446649af 100644
--- a/libcontainer/process_linux.go
+++ b/libcontainer/process_linux.go
@@ -39,13 +39,9 @@ type parentProcess interface {
 
 	// startTime returns the process start time.
 	startTime() (uint64, error)
-
 	signal(os.Signal) error
-
 	externalDescriptors() []string
-
 	setExternalDescriptors(fds []string)
-
 	forwardChildLogs() chan error
 }
 
diff --git a/update.go b/update.go
index d02e7af9..9ce5a2e8 100644
--- a/update.go
+++ b/update.go
@@ -194,7 +194,6 @@ other options are ignored.
 				opt  string
 				dest *uint64
 			}{
-
 				{"cpu-period", r.CPU.Period},
 				{"cpu-rt-period", r.CPU.RealtimePeriod},
 				{"cpu-share", r.CPU.Shares},
@@ -211,7 +210,6 @@ other options are ignored.
 				opt  string
 				dest *int64
 			}{
-
 				{"cpu-quota", r.CPU.Quota},
 				{"cpu-rt-runtime", r.CPU.RealtimeRuntime},
 			} {


Test patch:
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 72f6eb37..306bb0db 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -35,7 +35,7 @@ jobs:
     steps:
 
     - name: checkout
-      uses: actions/checkout@v2
+      uses: actions/checkout@v3
 
     - name: install deps
       if: matrix.criu == ''
@@ -105,7 +105,7 @@ jobs:
     steps:
 
     - name: checkout
-      uses: actions/checkout@v2
+      uses: actions/checkout@v3
 
     - name: install deps
       run: |
diff --git a/libcontainer/cgroups/ebpf/devicefilter/devicefilter_test.go b/libcontainer/cgroups/ebpf/devicefilter/devicefilter_test.go
index a8fc562d..d2793358 100644
--- a/libcontainer/cgroups/ebpf/devicefilter/devicefilter_test.go
+++ b/libcontainer/cgroups/ebpf/devicefilter/devicefilter_test.go
@@ -153,8 +153,7 @@ func TestDeviceFilter_Privileged(t *testing.T) {
 			Allow:       true,
 		},
 	}
-	expected :=
-		`
+	expected := `
 // load parameters into registers
         0: LdXMemW dst: r2 src: r1 off: 0 imm: 0
         1: And32Imm dst: r2 imm: 65535