|
@@ -307,6 +307,27 @@ func (runtime *Runtime) restore() error {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
+func (runtime *Runtime) UpdateCapabilities(quiet bool) {
|
|
|
+ if cgroupMemoryMountpoint, err := FindCgroupMountpoint("memory"); err != nil {
|
|
|
+ if !quiet {
|
|
|
+ log.Printf("WARNING: %s\n", err)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ _, err1 := ioutil.ReadFile(path.Join(cgroupMemoryMountpoint, "memory.limit_in_bytes"))
|
|
|
+ _, err2 := ioutil.ReadFile(path.Join(cgroupMemoryMountpoint, "memory.soft_limit_in_bytes"))
|
|
|
+ runtime.capabilities.MemoryLimit = err1 == nil && err2 == nil
|
|
|
+ if !runtime.capabilities.MemoryLimit && !quiet {
|
|
|
+ log.Printf("WARNING: Your kernel does not support cgroup memory limit.")
|
|
|
+ }
|
|
|
+
|
|
|
+ _, err = ioutil.ReadFile(path.Join(cgroupMemoryMountpoint, "memory.memsw.limit_in_bytes"))
|
|
|
+ runtime.capabilities.SwapLimit = err == nil
|
|
|
+ if !runtime.capabilities.SwapLimit && !quiet {
|
|
|
+ log.Printf("WARNING: Your kernel does not support cgroup swap limit.")
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
// FIXME: harmonize with NewGraph()
|
|
|
func NewRuntime(autoRestart bool) (*Runtime, error) {
|
|
|
runtime, err := NewRuntimeFromDirectory("/var/lib/docker", autoRestart)
|
|
@@ -322,23 +343,7 @@ func NewRuntime(autoRestart bool) (*Runtime, error) {
|
|
|
log.Printf("WARNING: You are running linux kernel version %s, which might be unstable running docker. Please upgrade your kernel to 3.8.0.", k.String())
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- if cgroupMemoryMountpoint, err := FindCgroupMountpoint("memory"); err != nil {
|
|
|
- log.Printf("WARNING: %s\n", err)
|
|
|
- } else {
|
|
|
- _, err1 := ioutil.ReadFile(path.Join(cgroupMemoryMountpoint, "memory.limit_in_bytes"))
|
|
|
- _, err2 := ioutil.ReadFile(path.Join(cgroupMemoryMountpoint, "memory.soft_limit_in_bytes"))
|
|
|
- runtime.capabilities.MemoryLimit = err1 == nil && err2 == nil
|
|
|
- if !runtime.capabilities.MemoryLimit {
|
|
|
- log.Printf("WARNING: Your kernel does not support cgroup memory limit.")
|
|
|
- }
|
|
|
-
|
|
|
- _, err = ioutil.ReadFile(path.Join(cgroupMemoryMountpoint, "memory.memsw.limit_in_bytes"))
|
|
|
- runtime.capabilities.SwapLimit = err == nil
|
|
|
- if !runtime.capabilities.SwapLimit {
|
|
|
- log.Printf("WARNING: Your kernel does not support cgroup swap limit.")
|
|
|
- }
|
|
|
- }
|
|
|
+ runtime.UpdateCapabilities(false)
|
|
|
return runtime, nil
|
|
|
}
|
|
|
|