... | ... |
@@ -305,18 +305,22 @@ func NewRuntime() (*Runtime, error) { |
305 | 305 |
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()) |
306 | 306 |
} |
307 | 307 |
|
308 |
- cgroupMemoryMountpoint, err := FindCgroupMountpoint("memory") |
|
309 |
- if err != nil { |
|
310 |
- return nil, err |
|
311 |
- } |
|
312 |
- |
|
313 |
- _, err1 := ioutil.ReadFile(path.Join(cgroupMemoryMountpoint, "/memory.limit_in_bytes")) |
|
314 |
- _, err2 := ioutil.ReadFile(path.Join(cgroupMemoryMountpoint, "memory.soft_limit_in_bytes")) |
|
315 |
- runtime.capabilities.MemoryLimit = err1 == nil && err2 == nil |
|
316 |
- |
|
317 |
- _, err = ioutil.ReadFile(path.Join(cgroupMemoryMountpoint, "memeory.memsw.limit_in_bytes")) |
|
318 |
- runtime.capabilities.SwapLimit = err == nil |
|
308 |
+ if cgroupMemoryMountpoint, err := FindCgroupMountpoint("memory"); err != nil { |
|
309 |
+ log.Printf("WARNING: %s\n", err) |
|
310 |
+ } else { |
|
311 |
+ _, err1 := ioutil.ReadFile(path.Join(cgroupMemoryMountpoint, "memory.limit_in_bytes")) |
|
312 |
+ _, err2 := ioutil.ReadFile(path.Join(cgroupMemoryMountpoint, "memory.soft_limit_in_bytes")) |
|
313 |
+ runtime.capabilities.MemoryLimit = err1 == nil && err2 == nil |
|
314 |
+ if !runtime.capabilities.MemoryLimit { |
|
315 |
+ log.Printf("WARNING: Your kernel does not support cgroup memory limit.") |
|
316 |
+ } |
|
319 | 317 |
|
318 |
+ _, err = ioutil.ReadFile(path.Join(cgroupMemoryMountpoint, "memory.memsw.limit_in_bytes")) |
|
319 |
+ runtime.capabilities.SwapLimit = err == nil |
|
320 |
+ if !runtime.capabilities.SwapLimit { |
|
321 |
+ log.Printf("WARNING: Your kernel does not support cgroup swap limit.") |
|
322 |
+ } |
|
323 |
+ } |
|
320 | 324 |
return runtime, nil |
321 | 325 |
} |
322 | 326 |
|
... | ... |
@@ -503,7 +503,6 @@ func FindCgroupMountpoint(cgroupType string) (string, error) { |
503 | 503 |
if len(r) == 2 { |
504 | 504 |
return r[1], nil |
505 | 505 |
} |
506 |
- fmt.Printf("line: %s (%d)\n", line, len(r)) |
|
507 | 506 |
} |
508 |
- return "", fmt.Errorf("cgroup mountpoint not found") |
|
507 |
+ return "", fmt.Errorf("cgroup mountpoint not found for %s", cgroupType) |
|
509 | 508 |
} |