Merge pull request #29846 from thaJeztah/dont-create-init-path
do not create init-dir if not needed
This commit is contained in:
commit
9248351992
1 changed files with 12 additions and 3 deletions
|
@ -1190,6 +1190,12 @@ func (daemon *Daemon) initCgroupsPath(path string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
if daemon.configStore.CPURealtimePeriod == 0 && daemon.configStore.CPURealtimeRuntime == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Recursively create cgroup to ensure that the system and all parent cgroups have values set
|
||||
// for the period and runtime as this limits what the children can be set to.
|
||||
daemon.initCgroupsPath(filepath.Dir(path))
|
||||
|
||||
_, root, err := cgroups.FindCgroupMountpointAndRoot("cpu")
|
||||
|
@ -1199,15 +1205,18 @@ func (daemon *Daemon) initCgroupsPath(path string) error {
|
|||
|
||||
path = filepath.Join(root, path)
|
||||
sysinfo := sysinfo.New(true)
|
||||
if err := os.MkdirAll(path, 0755); err != nil && !os.IsExist(err) {
|
||||
return err
|
||||
}
|
||||
if sysinfo.CPURealtimePeriod && daemon.configStore.CPURealtimePeriod != 0 {
|
||||
if err := os.MkdirAll(path, 0755); err != nil && !os.IsExist(err) {
|
||||
return err
|
||||
}
|
||||
if err := ioutil.WriteFile(filepath.Join(path, "cpu.rt_period_us"), []byte(strconv.FormatInt(daemon.configStore.CPURealtimePeriod, 10)), 0700); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if sysinfo.CPURealtimeRuntime && daemon.configStore.CPURealtimeRuntime != 0 {
|
||||
if err := os.MkdirAll(path, 0755); err != nil && !os.IsExist(err) {
|
||||
return err
|
||||
}
|
||||
if err := ioutil.WriteFile(filepath.Join(path, "cpu.rt_runtime_us"), []byte(strconv.FormatInt(daemon.configStore.CPURealtimeRuntime, 10)), 0700); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue