Skip to content

Commit f1e92d8

Browse files
authored
Merge pull request #376 from AkihiroSuda/runtime-spec-v1.3.0
go.mod: github.com/opencontainers/runtime-spec v1.3.0
2 parents fa024e5 + 34ef430 commit f1e92d8

File tree

7 files changed

+16
-13
lines changed

7 files changed

+16
-13
lines changed

cgroup1/pids.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,11 @@ func (p *pidsController) Create(path string, resources *specs.LinuxResources) er
4747
if err := os.MkdirAll(p.Path(path), defaultDirPerm); err != nil {
4848
return err
4949
}
50-
if resources.Pids != nil && resources.Pids.Limit > 0 {
50+
if resources.Pids != nil && resources.Pids.Limit != nil &&
51+
*resources.Pids.Limit > 0 {
5152
return os.WriteFile(
5253
filepath.Join(p.Path(path), "pids.max"),
53-
[]byte(strconv.FormatInt(resources.Pids.Limit, 10)),
54+
[]byte(strconv.FormatInt(*resources.Pids.Limit, 10)),
5455
defaultFilePerm,
5556
)
5657
}

cgroup1/pids_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ func TestPids(t *testing.T) {
4343
}
4444
resources := specs.LinuxResources{}
4545
resources.Pids = &specs.LinuxPids{}
46-
resources.Pids.Limit = int64(10)
46+
pidsLimit := int64(10)
47+
resources.Pids.Limit = &pidsLimit
4748
err = pids.Create("test", &resources)
4849
if err != nil {
4950
t.Fatal(err)
@@ -69,7 +70,7 @@ func TestPids(t *testing.T) {
6970
t.Fatalf("expected pids limit %q but received %q",
7071
uint64(5), metrics.Pids.Current)
7172
}
72-
resources.Pids.Limit = int64(15)
73+
pidsLimit = 15
7374
err = pids.Update("test", &resources)
7475
if err != nil {
7576
t.Fatal(err)
@@ -203,9 +204,10 @@ func BenchmarkTestPids(b *testing.B) {
203204
if pids == nil {
204205
b.Fatal("pids is nil")
205206
}
207+
pidsLimit := int64(10)
206208
resources := specs.LinuxResources{
207209
Pids: &specs.LinuxPids{
208-
Limit: 10,
210+
Limit: &pidsLimit,
209211
},
210212
}
211213

cgroup2/utils.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,9 @@ func ToResources(spec *specs.LinuxResources) *Resources {
221221
}
222222
resources.HugeTlb = &hugeTlbUsage
223223
}
224-
if pids := spec.Pids; pids != nil {
224+
if pids := spec.Pids; pids != nil && pids.Limit != nil {
225225
resources.Pids = &Pids{
226-
Max: pids.Limit,
226+
Max: *pids.Limit,
227227
}
228228
}
229229
if i := spec.BlockIO; i != nil {

cmd/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ require (
1616
github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect
1717
github.com/godbus/dbus/v5 v5.1.0 // indirect
1818
github.com/moby/sys/userns v0.1.0 // indirect
19-
github.com/opencontainers/runtime-spec v1.2.0 // indirect
19+
github.com/opencontainers/runtime-spec v1.3.0 // indirect
2020
github.com/russross/blackfriday/v2 v2.1.0 // indirect
2121
github.com/sirupsen/logrus v1.9.3 // indirect
2222
golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f // indirect

cmd/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ github.com/mdlayher/socket v0.4.1 h1:eM9y2/jlbs1M615oshPQOHZzj6R6wMT7bX5NPiQvn2U
3131
github.com/mdlayher/socket v0.4.1/go.mod h1:cAqeGjoufqdxWkD7DkpyS+wcefOtmu5OQ8KuoJGIReA=
3232
github.com/moby/sys/userns v0.1.0 h1:tVLXkFOxVu9A64/yh59slHVv9ahO9UIev4JZusOLG/g=
3333
github.com/moby/sys/userns v0.1.0/go.mod h1:IHUYgu/kao6N8YZlp9Cf444ySSvCmDlmzUcYfDHOl28=
34-
github.com/opencontainers/runtime-spec v1.2.0 h1:z97+pHb3uELt/yiAWD691HNHQIF07bE7dzrbT927iTk=
35-
github.com/opencontainers/runtime-spec v1.2.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
34+
github.com/opencontainers/runtime-spec v1.3.0 h1:YZupQUdctfhpZy3TM39nN9Ika5CBWT5diQ8ibYCRkxg=
35+
github.com/opencontainers/runtime-spec v1.3.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
3636
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
3737
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
3838
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ require (
99
github.com/docker/go-units v0.5.0
1010
github.com/godbus/dbus/v5 v5.1.0
1111
github.com/moby/sys/userns v0.1.0
12-
github.com/opencontainers/runtime-spec v1.2.0
12+
github.com/opencontainers/runtime-spec v1.3.0
1313
github.com/stretchr/testify v1.8.4
1414
go.uber.org/goleak v1.1.12
1515
golang.org/x/sys v0.27.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ github.com/mdlayher/socket v0.4.1 h1:eM9y2/jlbs1M615oshPQOHZzj6R6wMT7bX5NPiQvn2U
3333
github.com/mdlayher/socket v0.4.1/go.mod h1:cAqeGjoufqdxWkD7DkpyS+wcefOtmu5OQ8KuoJGIReA=
3434
github.com/moby/sys/userns v0.1.0 h1:tVLXkFOxVu9A64/yh59slHVv9ahO9UIev4JZusOLG/g=
3535
github.com/moby/sys/userns v0.1.0/go.mod h1:IHUYgu/kao6N8YZlp9Cf444ySSvCmDlmzUcYfDHOl28=
36-
github.com/opencontainers/runtime-spec v1.2.0 h1:z97+pHb3uELt/yiAWD691HNHQIF07bE7dzrbT927iTk=
37-
github.com/opencontainers/runtime-spec v1.2.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
36+
github.com/opencontainers/runtime-spec v1.3.0 h1:YZupQUdctfhpZy3TM39nN9Ika5CBWT5diQ8ibYCRkxg=
37+
github.com/opencontainers/runtime-spec v1.3.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
3838
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
3939
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
4040
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=

0 commit comments

Comments
 (0)