Skip to content

Commit 03db4d6

Browse files
authored
Merge pull request #4259 from kolyshkin/fix-cpu-burst
libct/cg/fs: don't write cpu_burst twice on ENOENT
2 parents 488c077 + b032fea commit 03db4d6

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)