Skip to content

Commit 1f3fa72

Browse files
authored
Merge pull request #3976 from kolyshkin/1.1-go-1.21-ci
[1.1] Add go 1.21 to CI
2 parents aa68c40 + bdbfe04 commit 1f3fa72

File tree

8 files changed

+86
-58
lines changed

8 files changed

+86
-58
lines changed

.cirrus.yml

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ task:
3131

3232
host_info_script: |
3333
uname -a
34-
echo "-----"
34+
# -----
3535
cat /etc/os-release
36-
echo "-----"
37-
cat /proc/cpuinfo
38-
echo "-----"
36+
# -----
3937
df -T
38+
# -----
39+
cat /proc/cpuinfo
4040
install_libvirt_vagrant_script: |
4141
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
4242
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
@@ -77,7 +77,7 @@ task:
7777
env:
7878
HOME: /root
7979
CIRRUS_WORKING_DIR: /home/runc
80-
GO_VERSION: "1.19.8"
80+
GO_VERSION: "1.20"
8181
BATS_VERSION: "v1.9.0"
8282
RPMS: gcc git iptables jq glibc-static libseccomp-devel make criu fuse-sshfs
8383
# yamllint disable rule:key-duplicates
@@ -130,7 +130,10 @@ task:
130130
# Use --whatprovides since some packages are renamed.
131131
rpm -q --whatprovides $RPMS
132132
# install Go
133-
curl -fsSL "https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz" | tar Cxz /usr/local
133+
PREFIX="https://go.dev/dl/"
134+
# Find out the latest minor release URL.
135+
eval $(curl -fsSL "${PREFIX}?mode=json" | jq -r --arg Ver "$GO_VERSION" '.[] | select(.version | startswith("go\($Ver)")) | .files[] | select(.os == "linux" and .arch == "amd64" and .kind == "archive") | "filename=\"" + .filename + "\""')
136+
curl -fsSL "$PREFIX$filename" | tar Cxz /usr/local
134137
# install bats
135138
cd /tmp
136139
git clone https://github.com/bats-core/bats-core
@@ -158,14 +161,16 @@ task:
158161
systemctl restart sshd
159162
host_info_script: |
160163
uname -a
161-
echo "-----"
164+
# -----
165+
/usr/local/go/bin/go version
166+
# -----
167+
systemctl --version
168+
# -----
162169
cat /etc/os-release
163-
echo "-----"
164-
cat /proc/cpuinfo
165-
echo "-----"
170+
# -----
166171
df -T
167-
echo "-----"
168-
systemctl --version
172+
# -----
173+
cat /proc/cpuinfo
169174
check_config_script: |
170175
/home/runc/script/check-config.sh
171176
unit_tests_script: |

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
strategy:
2222
fail-fast: false
2323
matrix:
24-
go-version: [1.17.x, 1.19.x, 1.20.x]
24+
go-version: [1.17.x, 1.20.x, 1.21.x]
2525
rootless: ["rootless", ""]
2626
race: ["-race", ""]
2727
criu: [""]
@@ -60,7 +60,7 @@ jobs:
6060
rm -rf ~/criu
6161
6262
- name: install go ${{ matrix.go-version }}
63-
uses: actions/setup-go@v3
63+
uses: actions/setup-go@v4
6464
with:
6565
go-version: ${{ matrix.go-version }}
6666

@@ -119,7 +119,7 @@ jobs:
119119
sudo apt -q install libseccomp-dev libseccomp-dev:i386 gcc-multilib criu
120120
121121
- name: install go
122-
uses: actions/setup-go@v3
122+
uses: actions/setup-go@v4
123123
with:
124124
go-version: 1.x # Latest stable
125125

.github/workflows/validate.yml

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
- release-*
99
pull_request:
1010
env:
11-
GO_VERSION: 1.19.x
11+
GO_VERSION: 1.20.x
1212

1313
jobs:
1414
keyring:
@@ -24,16 +24,17 @@ jobs:
2424
- uses: actions/checkout@v3
2525
with:
2626
fetch-depth: 2
27-
- uses: actions/setup-go@v3
27+
- uses: actions/setup-go@v4
2828
with:
2929
go-version: "${{ env.GO_VERSION }}"
30+
cache: false # golangci-lint-action does its own caching
3031
- name: install deps
3132
run: |
3233
sudo apt -q update
3334
sudo apt -q install libseccomp-dev
3435
- uses: golangci/golangci-lint-action@v3
3536
with:
36-
version: v1.48
37+
version: v1.53
3738
# Extra linters, only checking new code from a pull request.
3839
- name: lint-extra
3940
if: github.event_name == 'pull_request'
@@ -48,7 +49,7 @@ jobs:
4849
steps:
4950
- uses: actions/checkout@v3
5051
- name: install go
51-
uses: actions/setup-go@v3
52+
uses: actions/setup-go@v4
5253
with:
5354
go-version: "${{ env.GO_VERSION }}"
5455
- name: compile with no build tags
@@ -101,17 +102,9 @@ jobs:
101102
steps:
102103
- uses: actions/checkout@v3
103104
- name: install go
104-
uses: actions/setup-go@v3
105+
uses: actions/setup-go@v4
105106
with:
106107
go-version: "${{ env.GO_VERSION }}"
107-
- name: cache go mod and $GOCACHE
108-
uses: actions/cache@v3
109-
with:
110-
path: |
111-
~/go/pkg/mod
112-
~/.cache/go-build
113-
key: ${{ runner.os }}-go.sum-${{ hashFiles('**/go.sum') }}
114-
restore-keys: ${{ runner.os }}-go.sum-
115108
- name: verify deps
116109
run: make verify-dependencies
117110

Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,7 @@ ENV PKG_CONFIG_PATH=/opt/libseccomp/lib/pkgconfig
6262
RUN git config --global --add safe.directory /go/src/github.com/opencontainers/runc
6363

6464
WORKDIR /go/src/github.com/opencontainers/runc
65+
66+
# Fixup for cgroup v2.
67+
COPY script/prepare-cgroup-v2.sh /
68+
ENTRYPOINT [ "/prepare-cgroup-v2.sh" ]

libcontainer/cgroups/file_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ func TestOpenat2(t *testing.T) {
5858
{"/sys/fs/cgroup", "/cgroup.controllers"},
5959
{"/sys/fs/cgroup/", "cgroup.controllers"},
6060
{"/sys/fs/cgroup/", "/cgroup.controllers"},
61-
{"/sys/fs/cgroup/user.slice", "cgroup.controllers"},
62-
{"/sys/fs/cgroup/user.slice/", "/cgroup.controllers"},
6361
{"/", "/sys/fs/cgroup/cgroup.controllers"},
6462
{"/", "sys/fs/cgroup/cgroup.controllers"},
6563
{"/sys/fs/cgroup/cgroup.controllers", ""},

libcontainer/cgroups/manager/manager_test.go

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,53 @@ package manager
33
import (
44
"testing"
55

6+
"github.com/opencontainers/runc/libcontainer/cgroups/systemd"
67
"github.com/opencontainers/runc/libcontainer/configs"
78
)
89

910
// TestNilResources checks that a cgroup manager do not panic when
1011
// config.Resources is nil. While it does not make sense to use a
1112
// manager with no resources, it should not result in a panic.
1213
//
13-
// This tests either v1 or v2 managers (both fs and systemd),
14-
// depending on what cgroup version is available on the host.
14+
// This tests either v1 or v2 fs cgroup manager, depending on which
15+
// cgroup version is available.
1516
func TestNilResources(t *testing.T) {
16-
for _, sd := range []bool{false, true} {
17-
cg := &configs.Cgroup{} // .Resources is nil
18-
cg.Systemd = sd
19-
mgr, err := New(cg)
17+
testNilResources(t, false)
18+
}
19+
20+
// TestNilResourcesSystemd is the same as TestNilResources,
21+
// only checking the systemd cgroup manager.
22+
func TestNilResourcesSystemd(t *testing.T) {
23+
if !systemd.IsRunningSystemd() {
24+
t.Skip("requires systemd")
25+
}
26+
testNilResources(t, true)
27+
}
28+
29+
func testNilResources(t *testing.T, systemd bool) {
30+
cg := &configs.Cgroup{} // .Resources is nil
31+
cg.Systemd = systemd
32+
mgr, err := New(cg)
33+
if err != nil {
34+
// Some managers require non-nil Resources during
35+
// instantiation -- provide and retry. In such case
36+
// we're mostly testing Set(nil) below.
37+
cg.Resources = &configs.Resources{}
38+
mgr, err = New(cg)
2039
if err != nil {
21-
// Some managers require non-nil Resources during
22-
// instantiation -- provide and retry. In such case
23-
// we're mostly testing Set(nil) below.
24-
cg.Resources = &configs.Resources{}
25-
mgr, err = New(cg)
26-
if err != nil {
27-
t.Error(err)
28-
continue
29-
}
40+
t.Fatal(err)
3041
}
31-
_ = mgr.Apply(-1)
32-
_ = mgr.Set(nil)
33-
_ = mgr.Freeze(configs.Thawed)
34-
_ = mgr.Exists()
35-
_, _ = mgr.GetAllPids()
36-
_, _ = mgr.GetCgroups()
37-
_, _ = mgr.GetFreezerState()
38-
_ = mgr.Path("")
39-
_ = mgr.GetPaths()
40-
_, _ = mgr.GetStats()
41-
_, _ = mgr.OOMKillCount()
42-
_ = mgr.Destroy()
4342
}
43+
_ = mgr.Apply(-1)
44+
_ = mgr.Set(nil)
45+
_ = mgr.Freeze(configs.Thawed)
46+
_ = mgr.Exists()
47+
_, _ = mgr.GetAllPids()
48+
_, _ = mgr.GetCgroups()
49+
_, _ = mgr.GetFreezerState()
50+
_ = mgr.Path("")
51+
_ = mgr.GetPaths()
52+
_, _ = mgr.GetStats()
53+
_, _ = mgr.OOMKillCount()
54+
_ = mgr.Destroy()
4455
}

libcontainer/user/user.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ func ParseGroupFilter(r io.Reader, filter func(Group) bool) ([]Group, error) {
201201
if err != nil {
202202
// We should return no error if EOF is reached
203203
// without a match.
204-
if err == io.EOF { //nolint:errorlint // comparison with io.EOF is legit, https://github.com/polyfloyd/go-errorlint/pull/12
204+
if err == io.EOF {
205205
err = nil
206206
}
207207
return out, err

script/prepare-cgroup-v2.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
#
3+
# This script is used from ../Dockerfile as the ENTRYPOINT. It sets up cgroup
4+
# delegation for cgroup v2 to make sure runc tests can be properly run inside
5+
# a container.
6+
7+
# Only do this for cgroup v2.
8+
if [ -f /sys/fs/cgroup/cgroup.controllers ]; then
9+
set -x
10+
# Move the current process to a sub-cgroup.
11+
mkdir /sys/fs/cgroup/init
12+
echo 0 >/sys/fs/cgroup/init/cgroup.procs
13+
# Enable all controllers.
14+
sed 's/\b\w/+\0/g' <"/sys/fs/cgroup/cgroup.controllers" >"/sys/fs/cgroup/cgroup.subtree_control"
15+
fi
16+
17+
exec "$@"

0 commit comments

Comments
 (0)