Skip to content

Commit

Permalink
Merge pull request #3976 from kolyshkin/1.1-go-1.21-ci
Browse files Browse the repository at this point in the history
[1.1] Add go 1.21 to CI
  • Loading branch information
mrunalp authored Aug 10, 2023
2 parents aa68c40 + bdbfe04 commit 1f3fa72
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 58 deletions.
29 changes: 17 additions & 12 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ task:

host_info_script: |
uname -a
echo "-----"
# -----
cat /etc/os-release
echo "-----"
cat /proc/cpuinfo
echo "-----"
# -----
df -T
# -----
cat /proc/cpuinfo
install_libvirt_vagrant_script: |
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
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
Expand Down Expand Up @@ -77,7 +77,7 @@ task:
env:
HOME: /root
CIRRUS_WORKING_DIR: /home/runc
GO_VERSION: "1.19.8"
GO_VERSION: "1.20"
BATS_VERSION: "v1.9.0"
RPMS: gcc git iptables jq glibc-static libseccomp-devel make criu fuse-sshfs
# yamllint disable rule:key-duplicates
Expand Down Expand Up @@ -130,7 +130,10 @@ task:
# Use --whatprovides since some packages are renamed.
rpm -q --whatprovides $RPMS
# install Go
curl -fsSL "https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz" | tar Cxz /usr/local
PREFIX="https://go.dev/dl/"
# Find out the latest minor release URL.
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 + "\""')
curl -fsSL "$PREFIX$filename" | tar Cxz /usr/local
# install bats
cd /tmp
git clone https://github.com/bats-core/bats-core
Expand Down Expand Up @@ -158,14 +161,16 @@ task:
systemctl restart sshd
host_info_script: |
uname -a
echo "-----"
# -----
/usr/local/go/bin/go version
# -----
systemctl --version
# -----
cat /etc/os-release
echo "-----"
cat /proc/cpuinfo
echo "-----"
# -----
df -T
echo "-----"
systemctl --version
# -----
cat /proc/cpuinfo
check_config_script: |
/home/runc/script/check-config.sh
unit_tests_script: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
strategy:
fail-fast: false
matrix:
go-version: [1.17.x, 1.19.x, 1.20.x]
go-version: [1.17.x, 1.20.x, 1.21.x]
rootless: ["rootless", ""]
race: ["-race", ""]
criu: [""]
Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:
rm -rf ~/criu
- name: install go ${{ matrix.go-version }}
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}

Expand Down Expand Up @@ -119,7 +119,7 @@ jobs:
sudo apt -q install libseccomp-dev libseccomp-dev:i386 gcc-multilib criu
- name: install go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: 1.x # Latest stable

Expand Down
19 changes: 6 additions & 13 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
- release-*
pull_request:
env:
GO_VERSION: 1.19.x
GO_VERSION: 1.20.x

jobs:
keyring:
Expand All @@ -24,16 +24,17 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 2
- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: "${{ env.GO_VERSION }}"
cache: false # golangci-lint-action does its own caching
- name: install deps
run: |
sudo apt -q update
sudo apt -q install libseccomp-dev
- uses: golangci/golangci-lint-action@v3
with:
version: v1.48
version: v1.53
# Extra linters, only checking new code from a pull request.
- name: lint-extra
if: github.event_name == 'pull_request'
Expand All @@ -48,7 +49,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: install go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: "${{ env.GO_VERSION }}"
- name: compile with no build tags
Expand Down Expand Up @@ -101,17 +102,9 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: install go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: "${{ env.GO_VERSION }}"
- name: cache go mod and $GOCACHE
uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go.sum-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go.sum-
- name: verify deps
run: make verify-dependencies

Expand Down
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,7 @@ ENV PKG_CONFIG_PATH=/opt/libseccomp/lib/pkgconfig
RUN git config --global --add safe.directory /go/src/github.com/opencontainers/runc

WORKDIR /go/src/github.com/opencontainers/runc

# Fixup for cgroup v2.
COPY script/prepare-cgroup-v2.sh /
ENTRYPOINT [ "/prepare-cgroup-v2.sh" ]
2 changes: 0 additions & 2 deletions libcontainer/cgroups/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ func TestOpenat2(t *testing.T) {
{"/sys/fs/cgroup", "/cgroup.controllers"},
{"/sys/fs/cgroup/", "cgroup.controllers"},
{"/sys/fs/cgroup/", "/cgroup.controllers"},
{"/sys/fs/cgroup/user.slice", "cgroup.controllers"},
{"/sys/fs/cgroup/user.slice/", "/cgroup.controllers"},
{"/", "/sys/fs/cgroup/cgroup.controllers"},
{"/", "sys/fs/cgroup/cgroup.controllers"},
{"/sys/fs/cgroup/cgroup.controllers", ""},
Expand Down
65 changes: 38 additions & 27 deletions libcontainer/cgroups/manager/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,53 @@ package manager
import (
"testing"

"github.com/opencontainers/runc/libcontainer/cgroups/systemd"
"github.com/opencontainers/runc/libcontainer/configs"
)

// TestNilResources checks that a cgroup manager do not panic when
// config.Resources is nil. While it does not make sense to use a
// manager with no resources, it should not result in a panic.
//
// This tests either v1 or v2 managers (both fs and systemd),
// depending on what cgroup version is available on the host.
// This tests either v1 or v2 fs cgroup manager, depending on which
// cgroup version is available.
func TestNilResources(t *testing.T) {
for _, sd := range []bool{false, true} {
cg := &configs.Cgroup{} // .Resources is nil
cg.Systemd = sd
mgr, err := New(cg)
testNilResources(t, false)
}

// TestNilResourcesSystemd is the same as TestNilResources,
// only checking the systemd cgroup manager.
func TestNilResourcesSystemd(t *testing.T) {
if !systemd.IsRunningSystemd() {
t.Skip("requires systemd")
}
testNilResources(t, true)
}

func testNilResources(t *testing.T, systemd bool) {
cg := &configs.Cgroup{} // .Resources is nil
cg.Systemd = systemd
mgr, err := New(cg)
if err != nil {
// Some managers require non-nil Resources during
// instantiation -- provide and retry. In such case
// we're mostly testing Set(nil) below.
cg.Resources = &configs.Resources{}
mgr, err = New(cg)
if err != nil {
// Some managers require non-nil Resources during
// instantiation -- provide and retry. In such case
// we're mostly testing Set(nil) below.
cg.Resources = &configs.Resources{}
mgr, err = New(cg)
if err != nil {
t.Error(err)
continue
}
t.Fatal(err)
}
_ = mgr.Apply(-1)
_ = mgr.Set(nil)
_ = mgr.Freeze(configs.Thawed)
_ = mgr.Exists()
_, _ = mgr.GetAllPids()
_, _ = mgr.GetCgroups()
_, _ = mgr.GetFreezerState()
_ = mgr.Path("")
_ = mgr.GetPaths()
_, _ = mgr.GetStats()
_, _ = mgr.OOMKillCount()
_ = mgr.Destroy()
}
_ = mgr.Apply(-1)
_ = mgr.Set(nil)
_ = mgr.Freeze(configs.Thawed)
_ = mgr.Exists()
_, _ = mgr.GetAllPids()
_, _ = mgr.GetCgroups()
_, _ = mgr.GetFreezerState()
_ = mgr.Path("")
_ = mgr.GetPaths()
_, _ = mgr.GetStats()
_, _ = mgr.OOMKillCount()
_ = mgr.Destroy()
}
2 changes: 1 addition & 1 deletion libcontainer/user/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func ParseGroupFilter(r io.Reader, filter func(Group) bool) ([]Group, error) {
if err != nil {
// We should return no error if EOF is reached
// without a match.
if err == io.EOF { //nolint:errorlint // comparison with io.EOF is legit, https://github.com/polyfloyd/go-errorlint/pull/12
if err == io.EOF {
err = nil
}
return out, err
Expand Down
17 changes: 17 additions & 0 deletions script/prepare-cgroup-v2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
#
# This script is used from ../Dockerfile as the ENTRYPOINT. It sets up cgroup
# delegation for cgroup v2 to make sure runc tests can be properly run inside
# a container.

# Only do this for cgroup v2.
if [ -f /sys/fs/cgroup/cgroup.controllers ]; then
set -x
# Move the current process to a sub-cgroup.
mkdir /sys/fs/cgroup/init
echo 0 >/sys/fs/cgroup/init/cgroup.procs
# Enable all controllers.
sed 's/\b\w/+\0/g' <"/sys/fs/cgroup/cgroup.controllers" >"/sys/fs/cgroup/cgroup.subtree_control"
fi

exec "$@"

0 comments on commit 1f3fa72

Please sign in to comment.