commit 56f77d5ade945b3b8816a6c8acb328b7c6dce9a7
added support for cpu-rt-period and cpu-rt-runtime,
but always initialized the cgroup path, even if not
used.
As a result, containers failed to start on a
read-only filesystem.
This patch only creates the cgroup path if
one of these options is set.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
... | ... |
@@ -1190,6 +1190,12 @@ func (daemon *Daemon) initCgroupsPath(path string) error { |
1190 | 1190 |
return nil |
1191 | 1191 |
} |
1192 | 1192 |
|
1193 |
+ if daemon.configStore.CPURealtimePeriod == 0 && daemon.configStore.CPURealtimeRuntime == 0 { |
|
1194 |
+ return nil |
|
1195 |
+ } |
|
1196 |
+ |
|
1197 |
+ // Recursively create cgroup to ensure that the system and all parent cgroups have values set |
|
1198 |
+ // for the period and runtime as this limits what the children can be set to. |
|
1193 | 1199 |
daemon.initCgroupsPath(filepath.Dir(path)) |
1194 | 1200 |
|
1195 | 1201 |
_, root, err := cgroups.FindCgroupMountpointAndRoot("cpu") |
... | ... |
@@ -1199,15 +1205,18 @@ func (daemon *Daemon) initCgroupsPath(path string) error { |
1199 | 1199 |
|
1200 | 1200 |
path = filepath.Join(root, path) |
1201 | 1201 |
sysinfo := sysinfo.New(true) |
1202 |
- if err := os.MkdirAll(path, 0755); err != nil && !os.IsExist(err) { |
|
1203 |
- return err |
|
1204 |
- } |
|
1205 | 1202 |
if sysinfo.CPURealtimePeriod && daemon.configStore.CPURealtimePeriod != 0 { |
1203 |
+ if err := os.MkdirAll(path, 0755); err != nil && !os.IsExist(err) { |
|
1204 |
+ return err |
|
1205 |
+ } |
|
1206 | 1206 |
if err := ioutil.WriteFile(filepath.Join(path, "cpu.rt_period_us"), []byte(strconv.FormatInt(daemon.configStore.CPURealtimePeriod, 10)), 0700); err != nil { |
1207 | 1207 |
return err |
1208 | 1208 |
} |
1209 | 1209 |
} |
1210 | 1210 |
if sysinfo.CPURealtimeRuntime && daemon.configStore.CPURealtimeRuntime != 0 { |
1211 |
+ if err := os.MkdirAll(path, 0755); err != nil && !os.IsExist(err) { |
|
1212 |
+ return err |
|
1213 |
+ } |
|
1211 | 1214 |
if err := ioutil.WriteFile(filepath.Join(path, "cpu.rt_runtime_us"), []byte(strconv.FormatInt(daemon.configStore.CPURealtimeRuntime, 10)), 0700); err != nil { |
1212 | 1215 |
return err |
1213 | 1216 |
} |