Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-24.04, ubuntu-24.04-arm]
go-version: [1.23.x, 1.24.x]
go-version: [1.24.x, 1.25.x]
rootless: ["rootless", ""]
race: ["-race", ""]
criu: ["", "criu-dev"]
exclude:
# Disable most of criu-dev jobs, as they are expensive
# (need to compile criu) and don't add much value/coverage.
- criu: criu-dev
go-version: 1.23.x
go-version: 1.24.x
- criu: criu-dev
rootless: rootless
# Do race detection only on latest Go.
- race: -race
go-version: 1.23.x
go-version: 1.24.x

runs-on: ${{ matrix.os }}

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG GO_VERSION=1.23
ARG GO_VERSION=1.24
ARG BATS_VERSION=v1.11.0
ARG LIBSECCOMP_VERSION=2.5.6

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ A third party security audit was performed by Cure53, you can see the full repor

## Building

`runc` only supports Linux. See the header of [`go.mod`](./go.mod) for the required Go version.
`runc` only supports Linux. See the header of [`go.mod`](./go.mod) for the minimally required Go version.

### Pre-Requisites

Expand Down
2 changes: 1 addition & 1 deletion exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func getSubCgroupPaths(args []string) (map[string]string, error) {
// Split into controller:path.
if ctr, path, ok := strings.Cut(c, ":"); ok {
// There may be a few comma-separated controllers.
for _, ctrl := range strings.Split(ctr, ",") {
for ctrl := range strings.SplitSeq(ctr, ",") {
if ctrl == "" {
return nil, fmt.Errorf("invalid --cgroup argument: %s (empty <controller> prefix)", c)
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/opencontainers/runc

go 1.23.0
go 1.24.0

require (
github.com/checkpoint-restore/go-criu/v7 v7.2.0
Expand Down
2 changes: 1 addition & 1 deletion libcontainer/configs/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ func toCPUSet(str string) (*unix.CPUSet, error) {
return int(ret), nil
}

for _, r := range strings.Split(str, ",") {
for r := range strings.SplitSeq(str, ",") {
// Allow extra spaces around.
r = strings.TrimSpace(r)
// Allow empty elements (extra commas).
Expand Down
2 changes: 1 addition & 1 deletion libcontainer/configs/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestUnmarshalHooks(t *testing.T) {

for _, hookName := range configs.HookNameList {
hooks := configs.Hooks{}
err = hooks.UnmarshalJSON([]byte(fmt.Sprintf(`{"%s" :[%s]}`, hookName, hookJson)))
err = hooks.UnmarshalJSON(fmt.Appendf(nil, `{"%s" :[%s]}`, hookName, hookJson))
if err != nil {
t.Fatal(err)
}
Expand Down
1 change: 0 additions & 1 deletion libcontainer/configs/tocpuset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ func TestToCPUSet(t *testing.T) {
}

for _, tc := range testCases {
tc := tc
t.Run(tc.in, func(t *testing.T) {
out, err := toCPUSet(tc.in)
t.Logf("toCPUSet(%q) = %v (error: %v)", tc.in, out, err)
Expand Down
2 changes: 1 addition & 1 deletion libcontainer/configs/validate/rootless.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func rootlessEUIDMount(config *configs.Config) error {
if !strings.Contains(mount.Data, "id=") {
continue
}
for _, opt := range strings.Split(mount.Data, ",") {
for opt := range strings.SplitSeq(mount.Data, ",") {
if str, ok := strings.CutPrefix(opt, "uid="); ok {
uid, err := strconv.Atoi(str)
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions libcontainer/configs/validate/rootless_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,7 @@ func BenchmarkRootlessEUIDMount(b *testing.B) {
},
}

b.ResetTimer()
for i := 0; i < b.N; i++ {
for b.Loop() {
err := rootlessEUIDMount(config)
if err != nil {
b.Fatal(err)
Expand Down
1 change: 0 additions & 1 deletion libcontainer/configs/validate/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,6 @@ func TestValidateIDMapMounts(t *testing.T) {
}

for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
config := tc.config
config.Rootfs = "/var"
Expand Down
6 changes: 2 additions & 4 deletions libcontainer/integration/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ func BenchmarkExecTrue(b *testing.B) {
}()
ok(b, err)

b.ResetTimer()
for i := 0; i < b.N; i++ {
for b.Loop() {
exec := &libcontainer.Process{
Cwd: "/",
Args: []string{"/bin/true"},
Expand Down Expand Up @@ -101,8 +100,7 @@ func BenchmarkExecInBigEnv(b *testing.B) {
wantOut.WriteString(e + "\n")
}

b.ResetTimer()
for i := 0; i < b.N; i++ {
for b.Loop() {
buffers := newStdBuffers()
exec := &libcontainer.Process{
Cwd: "/",
Expand Down
12 changes: 6 additions & 6 deletions libcontainer/integration/exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -850,8 +850,8 @@ func TestMountCgroupRO(t *testing.T) {
buffers := runContainerOk(t, config, "mount")

mountInfo := buffers.Stdout.String()
lines := strings.Split(mountInfo, "\n")
for _, l := range lines {
lines := strings.SplitSeq(mountInfo, "\n")
for l := range lines {
if strings.HasPrefix(l, "tmpfs on /sys/fs/cgroup") {
if !strings.Contains(l, "ro") ||
!strings.Contains(l, "nosuid") ||
Expand Down Expand Up @@ -892,8 +892,8 @@ func TestMountCgroupRW(t *testing.T) {
buffers := runContainerOk(t, config, "mount")

mountInfo := buffers.Stdout.String()
lines := strings.Split(mountInfo, "\n")
for _, l := range lines {
lines := strings.SplitSeq(mountInfo, "\n")
for l := range lines {
if strings.HasPrefix(l, "tmpfs on /sys/fs/cgroup") {
if !strings.Contains(l, "rw") ||
!strings.Contains(l, "nosuid") ||
Expand Down Expand Up @@ -1206,8 +1206,8 @@ func TestRootfsPropagationSlaveMount(t *testing.T) {
dir2cont = filepath.Join(dir1cont, filepath.Base(dir2host))

propagationInfo := stdout2.String()
lines := strings.Split(propagationInfo, "\n")
for _, l := range lines {
lines := strings.SplitSeq(propagationInfo, "\n")
for l := range lines {
linefields := strings.Split(l, " ")
if len(linefields) < 5 {
continue
Expand Down
2 changes: 1 addition & 1 deletion libcontainer/internal/userns/usernsfd_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func BenchmarkSpawnProc(b *testing.B) {
}
})

for i := 0; i < b.N; i++ {
for b.Loop() {
proc, err := spawnProc(mapping)
if err != nil {
b.Error(err)
Expand Down
2 changes: 1 addition & 1 deletion libcontainer/rootfs_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ func mountCgroupV1(m *configs.Mount, c *mountConfig) error {
}
}
for _, mc := range merged {
for _, ss := range strings.Split(mc, ",") {
for ss := range strings.SplitSeq(mc, ",") {
// symlink(2) is very dumb, it will just shove the path into
// the link and doesn't do any checks or relative path
// conversion. Also, don't error out if the cgroup already exists.
Expand Down
3 changes: 1 addition & 2 deletions libcontainer/specconv/spec_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,6 @@ func TestInitSystemdProps(t *testing.T) {
spec := &specs.Spec{}

for _, tc := range testCases {
tc := tc
spec.Annotations = map[string]string{tc.in.name: tc.in.value}

outMap, err := initSystemdProps(spec)
Expand Down Expand Up @@ -834,7 +833,7 @@ func TestCheckPropertyName(t *testing.T) {
}

func BenchmarkCheckPropertyName(b *testing.B) {
for i := 0; i < b.N; i++ {
for b.Loop() {
for _, s := range []string{"", "xx", "xxx", "someValidName", "A name", "Кир", "მადლობა", "合い言葉"} {
_ = checkPropertyName(s)
}
Expand Down
2 changes: 0 additions & 2 deletions libcontainer/system/kernelversion/kernel_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ func TestParseRelease(t *testing.T) {
{in: "3.-8", expectedErr: fmt.Errorf(`failed to parse kernel version "3.-8": expected integer`)},
}
for _, tc := range tests {
tc := tc
t.Run(tc.in, func(t *testing.T) {
version, err := parseRelease(tc.in)
if tc.expectedErr != nil {
Expand Down Expand Up @@ -126,7 +125,6 @@ func TestGreaterEqualThan(t *testing.T) {
},
}
for _, tc := range tests {
tc := tc
t.Run(tc.doc+": "+tc.in.String(), func(t *testing.T) {
ok, err := GreaterEqualThan(tc.in)
if err != nil {
Expand Down
2 changes: 0 additions & 2 deletions libcontainer/system/rlimit_linux.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//go:build go1.23

package system

import (
Expand Down
2 changes: 1 addition & 1 deletion notify_socket.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (s *notifySocket) run(pid1 int) error {
got := buf[0:r]
// systemd-ready sends a single datagram with the state string as payload,
// so we don't need to worry about partial messages.
for _, line := range bytes.Split(got, []byte{'\n'}) {
for line := range bytes.SplitSeq(got, []byte{'\n'}) {
if bytes.HasPrefix(got, []byte("READY=")) {
fileChan <- line
return
Expand Down
12 changes: 6 additions & 6 deletions types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ type CpuUsage struct {
}

type Cpu struct {
Usage CpuUsage `json:"usage,omitempty"`
Throttling Throttling `json:"throttling,omitempty"`
Usage CpuUsage `json:"usage,omitzero"`
Throttling Throttling `json:"throttling,omitzero"`
PSI *PSIStats `json:"psi,omitempty"`
}

Expand All @@ -103,10 +103,10 @@ type MemoryEntry struct {

type Memory struct {
Cache uint64 `json:"cache,omitempty"`
Usage MemoryEntry `json:"usage,omitempty"`
Swap MemoryEntry `json:"swap,omitempty"`
Kernel MemoryEntry `json:"kernel,omitempty"`
KernelTCP MemoryEntry `json:"kernelTCP,omitempty"`
Usage MemoryEntry `json:"usage,omitzero"`
Swap MemoryEntry `json:"swap,omitzero"`
Kernel MemoryEntry `json:"kernel,omitzero"`
KernelTCP MemoryEntry `json:"kernelTCP,omitzero"`
Raw map[string]uint64 `json:"raw,omitempty"`
PSI *PSIStats `json:"psi,omitempty"`
}
Expand Down
Loading