driver/docker: ignore error if container exists before cgroup can be written

This commit is contained in:
Nick Ethier 2021-04-19 23:38:35 -04:00
parent 49befcb8e0
commit 9d194bb2d9

View file

@ -1,9 +1,19 @@
package docker
import (
"strings"
"github.com/opencontainers/runc/libcontainer/cgroups"
)
func setCPUSetCgroup(path string, pid int) error {
return cgroups.WriteCgroupProc(path, pid)
// Sometimes the container exists before we can write the
// cgroup resulting in an error which can be ignored.
if err := cgroups.WriteCgroupProc(path, pid); err != nil {
if strings.Contains(err.Error(), "no such process") {
return nil
}
return err
}
return nil
}