Skip to content

Commit b032fea

Browse files
committed
libct/cg/fs: don't write cpu_burst twice on ENOENT
If CPU burst knob is non-existent, the current implementation (added in commit e158483) still tries to set it again after setting the new CPU quota, which is useless (and we have to ignore ENOENT again). Fix this. Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent 426c04b commit b032fea

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

libcontainer/cgroups/fs/cpu.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,11 @@ func (s *CpuGroup) Set(path string, r *configs.Resources) error {
8989
if r.CpuBurst != nil {
9090
burst = strconv.FormatUint(*r.CpuBurst, 10)
9191
if err := cgroups.WriteFile(path, "cpu.cfs_burst_us", burst); err != nil {
92-
// this is a special trick for burst feature, the current systemd and low version of kernel will not support it.
93-
// So, an `no such file or directory` error would be raised, and we can ignore it .
94-
if !errors.Is(err, unix.ENOENT) {
92+
if errors.Is(err, unix.ENOENT) {
93+
// If CPU burst knob is not available (e.g.
94+
// older kernel), ignore it.
95+
burst = ""
96+
} else {
9597
// Sometimes when the burst to be set is larger
9698
// than the current one, it is rejected by the kernel
9799
// (EINVAL) as old_quota/new_burst exceeds the parent
@@ -117,9 +119,7 @@ func (s *CpuGroup) Set(path string, r *configs.Resources) error {
117119
}
118120
if burst != "" {
119121
if err := cgroups.WriteFile(path, "cpu.cfs_burst_us", burst); err != nil {
120-
if !errors.Is(err, unix.ENOENT) {
121-
return err
122-
}
122+
return err
123123
}
124124
}
125125
}

0 commit comments

Comments
 (0)