Skip to content

Commit f89ac03

Browse files
committed
Add SetProcessExecCPUAffinity
1 parent 260e151 commit f89ac03

File tree

7 files changed

+83
-26
lines changed

7 files changed

+83
-26
lines changed

generate/generate.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,12 @@ func (g *Generator) SetProcessArgs(args []string) {
498498
g.Config.Process.Args = args
499499
}
500500

501+
// SetProcessExecCPUAffinity sets g.Config.Process.ExecCPUAffinity.
502+
func (g *Generator) SetProcessExecCPUAffinity(execCPUAffinity *rspec.CPUAffinity) {
503+
g.initConfigProcess()
504+
g.Config.Process.ExecCPUAffinity = execCPUAffinity
505+
}
506+
501507
// ClearProcessEnv clears g.Config.Process.Env.
502508
func (g *Generator) ClearProcessEnv() {
503509
if g.Config == nil || g.Config.Process == nil {

generate/generate_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import (
1010
"github.com/opencontainers/runtime-tools/generate"
1111
"github.com/opencontainers/runtime-tools/specerror"
1212
"github.com/opencontainers/runtime-tools/validate"
13+
14+
rspec "github.com/opencontainers/runtime-spec/specs-go"
1315
"github.com/stretchr/testify/assert"
1416
)
1517

@@ -155,3 +157,14 @@ func TestMultipleEnvCaching(t *testing.T) {
155157
g.AddMultipleProcessEnv([]string{})
156158
assert.Equal(t, []string(nil), g.Config.Process.Env)
157159
}
160+
161+
func TestSetProcessExecCPUAffinity(t *testing.T) {
162+
g, err := generate.New("linux")
163+
if err != nil {
164+
t.Fatal(err)
165+
}
166+
167+
g.SetProcessExecCPUAffinity(&rspec.CPUAffinity{Initial: "1", Final: "2"})
168+
assert.Equal(t, "1", g.Config.Process.ExecCPUAffinity.Initial)
169+
assert.Equal(t, "2", g.Config.Process.ExecCPUAffinity.Final)
170+
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ require (
99
github.com/mndrix/tap-go v0.0.0-20171203230836-629fa407e90b
1010
github.com/moby/sys/mountinfo v0.7.2
1111
github.com/mrunalp/fileutils v0.5.0
12-
github.com/opencontainers/runtime-spec v1.1.0
12+
github.com/opencontainers/runtime-spec v1.2.1
1313
github.com/opencontainers/selinux v1.9.1
1414
github.com/sirupsen/logrus v1.8.1
1515
github.com/stretchr/testify v1.3.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ github.com/moby/sys/mountinfo v0.7.2 h1:1shs6aH5s4o5H2zQLn796ADW1wMrIwHsyJ2v9Kou
1515
github.com/moby/sys/mountinfo v0.7.2/go.mod h1:1YOa8w8Ih7uW0wALDUgT1dTTSBrZ+HiBLGws92L2RU4=
1616
github.com/mrunalp/fileutils v0.5.0 h1:NKzVxiH7eSk+OQ4M+ZYW1K6h27RUV3MI6NUTsHhU6Z4=
1717
github.com/mrunalp/fileutils v0.5.0/go.mod h1:M1WthSahJixYnrXQl/DFQuteStB1weuxD2QJNHXfbSQ=
18-
github.com/opencontainers/runtime-spec v1.1.0 h1:HHUyrt9mwHUjtasSbXSMvs4cyFxh+Bll4AjJ9odEGpg=
19-
github.com/opencontainers/runtime-spec v1.1.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
18+
github.com/opencontainers/runtime-spec v1.2.1 h1:S4k4ryNgEpxW1dzyqffOmhI1BHYcjzU8lpJfSlR0xww=
19+
github.com/opencontainers/runtime-spec v1.2.1/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
2020
github.com/opencontainers/selinux v1.9.1 h1:b4VPEF3O5JLZgdTDBmGepaaIbAo0GqoF6EBRq5f/g3Y=
2121
github.com/opencontainers/selinux v1.9.1/go.mod h1:2i0OySw99QjzBBQByd1Gr9gSjvuho1lHsJxIJ3gGbJI=
2222
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=

vendor/github.com/opencontainers/runtime-spec/specs-go/config.go

Lines changed: 58 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/opencontainers/runtime-spec/specs-go/version.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/modules.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ github.com/moby/sys/mountinfo
2222
# github.com/mrunalp/fileutils v0.5.0
2323
## explicit; go 1.13
2424
github.com/mrunalp/fileutils
25-
# github.com/opencontainers/runtime-spec v1.1.0
25+
# github.com/opencontainers/runtime-spec v1.2.1
2626
## explicit
2727
github.com/opencontainers/runtime-spec/specs-go
2828
# github.com/opencontainers/selinux v1.9.1

0 commit comments

Comments
 (0)