Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 13aaafd

Browse files
committed
Bugfix: can't write to cpuset cgroup
Using linux resource in spec: ``` "resources": { "cpu": { "period": 100000, "quota": 40000 }, ... } ``` In this case, `resources.CPU` != nil but `resources.CPU.Cpus` and `resources.CPU.Mems` are empty strings, `cgroups` lib will write "" to cpuset.cpus and cpuset.mems in Cpuset group, then no process can be written in this cgroup any more. In this case, empty value means copying from parent but doesn't mean no CPU can be used in this cgroup. Signed-off-by: Wei Zhang <[email protected]>
1 parent 58556f5 commit 13aaafd

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

cpuset.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,21 +57,21 @@ func (c *cpusetController) Create(path string, resources *specs.LinuxResources)
5757
if resources.CPU != nil {
5858
for _, t := range []struct {
5959
name string
60-
value *string
60+
value string
6161
}{
6262
{
6363
name: "cpus",
64-
value: &resources.CPU.Cpus,
64+
value: resources.CPU.Cpus,
6565
},
6666
{
6767
name: "mems",
68-
value: &resources.CPU.Mems,
68+
value: resources.CPU.Mems,
6969
},
7070
} {
71-
if t.value != nil {
71+
if t.value != "" {
7272
if err := ioutil.WriteFile(
7373
filepath.Join(c.Path(path), fmt.Sprintf("cpuset.%s", t.name)),
74-
[]byte(*t.value),
74+
[]byte(t.value),
7575
defaultFilePerm,
7676
); err != nil {
7777
return err

0 commit comments

Comments
 (0)