Do not fail cgroups setup if parent cgroup does not exist.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
This commit is contained in:
parent
71a57166c1
commit
9bebc66042
|
@ -99,11 +99,12 @@ func (m *Manager) Apply(pid int) error {
|
|||
// created then join consists of writing the process pids to cgroup.procs
|
||||
p, err := d.path(name)
|
||||
if err != nil {
|
||||
if cgroups.IsNotFound(err) {
|
||||
continue
|
||||
}
|
||||
return err
|
||||
}
|
||||
if !cgroups.PathExists(p) {
|
||||
continue
|
||||
}
|
||||
|
||||
paths[name] = p
|
||||
}
|
||||
m.Paths = paths
|
||||
|
@ -173,6 +174,9 @@ func (m *Manager) Freeze(state configs.FreezerState) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !cgroups.PathExists(dir) {
|
||||
return cgroups.NewNotFoundError("freezer")
|
||||
}
|
||||
|
||||
prevState := m.Cgroups.Freezer
|
||||
m.Cgroups.Freezer = state
|
||||
|
@ -197,6 +201,9 @@ func (m *Manager) GetPids() ([]int, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !cgroups.PathExists(dir) {
|
||||
return nil, cgroups.NewNotFoundError("devices")
|
||||
}
|
||||
|
||||
return cgroups.ReadProcsFile(dir)
|
||||
}
|
||||
|
@ -237,17 +244,7 @@ func (raw *data) path(subsystem string) (string, error) {
|
|||
|
||||
// If the cgroup name/path is absolute do not look relative to the cgroup of the init process.
|
||||
if filepath.IsAbs(raw.cgroup) {
|
||||
path := filepath.Join(raw.root, subsystem, raw.cgroup)
|
||||
|
||||
if _, err := os.Stat(path); err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return "", cgroups.NewNotFoundError(subsystem)
|
||||
}
|
||||
|
||||
return "", err
|
||||
}
|
||||
|
||||
return path, nil
|
||||
return filepath.Join(raw.root, subsystem, raw.cgroup), nil
|
||||
}
|
||||
|
||||
parent, err := raw.parent(subsystem)
|
||||
|
|
|
@ -17,12 +17,9 @@ type CpusetGroup struct {
|
|||
func (s *CpusetGroup) Apply(d *data) error {
|
||||
dir, err := d.path("cpuset")
|
||||
if err != nil {
|
||||
if cgroups.IsNotFound(err) {
|
||||
return nil
|
||||
} else {
|
||||
return err
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
return s.ApplyDir(dir, d.c, d.pid)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue