2021-04-15 14:39:11 +00:00
|
|
|
package docker
|
|
|
|
|
|
|
|
import (
|
2021-04-20 03:38:35 +00:00
|
|
|
"strings"
|
|
|
|
|
2021-04-15 14:39:11 +00:00
|
|
|
"github.com/opencontainers/runc/libcontainer/cgroups"
|
|
|
|
)
|
|
|
|
|
|
|
|
func setCPUSetCgroup(path string, pid int) error {
|
2021-04-20 03:38:35 +00:00
|
|
|
// Sometimes the container exists before we can write the
|
|
|
|
// cgroup resulting in an error which can be ignored.
|
2021-06-09 15:00:39 +00:00
|
|
|
err := cgroups.WriteCgroupProc(path, pid)
|
|
|
|
if err != nil && strings.Contains(err.Error(), "no such process") {
|
|
|
|
return nil
|
2021-04-20 03:38:35 +00:00
|
|
|
}
|
2021-06-09 15:00:39 +00:00
|
|
|
return err
|
2021-04-15 14:39:11 +00:00
|
|
|
}
|