If memory cgroup is mounted, memory limit is always supported,
no need to check if these files are exist.
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
| ... | ... |
@@ -23,20 +23,16 @@ func New(quiet bool) *SysInfo {
|
| 23 | 23 |
sysInfo := &SysInfo{}
|
| 24 | 24 |
if cgroupMemoryMountpoint, err := cgroups.FindCgroupMountpoint("memory"); err != nil {
|
| 25 | 25 |
if !quiet {
|
| 26 |
- logrus.Warnf("%v", err)
|
|
| 26 |
+ logrus.Warnf("Your kernel does not support cgroup memory limit: %v", err)
|
|
| 27 | 27 |
} |
| 28 | 28 |
} else {
|
| 29 |
- _, err1 := ioutil.ReadFile(path.Join(cgroupMemoryMountpoint, "memory.limit_in_bytes")) |
|
| 30 |
- _, err2 := ioutil.ReadFile(path.Join(cgroupMemoryMountpoint, "memory.soft_limit_in_bytes")) |
|
| 31 |
- sysInfo.MemoryLimit = err1 == nil && err2 == nil |
|
| 32 |
- if !sysInfo.MemoryLimit && !quiet {
|
|
| 33 |
- logrus.Warn("Your kernel does not support cgroup memory limit.")
|
|
| 34 |
- } |
|
| 29 |
+ // If memory cgroup is mounted, MemoryLimit is always enabled. |
|
| 30 |
+ sysInfo.MemoryLimit = true |
|
| 35 | 31 |
|
| 36 |
- _, err = ioutil.ReadFile(path.Join(cgroupMemoryMountpoint, "memory.memsw.limit_in_bytes")) |
|
| 37 |
- sysInfo.SwapLimit = err == nil |
|
| 32 |
+ _, err1 := ioutil.ReadFile(path.Join(cgroupMemoryMountpoint, "memory.memsw.limit_in_bytes")) |
|
| 33 |
+ sysInfo.SwapLimit = err1 == nil |
|
| 38 | 34 |
if !sysInfo.SwapLimit && !quiet {
|
| 39 |
- logrus.Warn("Your kernel does not support cgroup swap limit.")
|
|
| 35 |
+ logrus.Warn("Your kernel does not support swap memory limit.")
|
|
| 40 | 36 |
} |
| 41 | 37 |
} |
| 42 | 38 |
|