Merge pull request #14579 from hqhq/hq_add_softlimit

Add support for memory reservation
This commit is contained in:
Jess Frazelle 2015-09-24 12:11:36 -07:00
commit ad3c33e73d
2 changed files with 13 additions and 5 deletions

View file

@ -31,6 +31,9 @@ type cgroupMemInfo struct {
// Whether swap limit is supported or not
SwapLimit bool
// Whether soft limit is supported or not
MemoryReservation bool
// Whether OOM killer disalbe is supported or not
OomKillDisable bool

View file

@ -49,6 +49,10 @@ func checkCgroupMem(quiet bool) cgroupMemInfo {
if !quiet && !swapLimit {
logrus.Warn("Your kernel does not support swap memory limit.")
}
memoryReservation := cgroupEnabled(mountPoint, "memory.soft_limit_in_bytes")
if !quiet && !memoryReservation {
logrus.Warn("Your kernel does not support memory reservation.")
}
oomKillDisable := cgroupEnabled(mountPoint, "memory.oom_control")
if !quiet && !oomKillDisable {
logrus.Warnf("Your kernel does not support oom control.")
@ -63,11 +67,12 @@ func checkCgroupMem(quiet bool) cgroupMemInfo {
}
return cgroupMemInfo{
MemoryLimit: true,
SwapLimit: swapLimit,
OomKillDisable: oomKillDisable,
MemorySwappiness: memorySwappiness,
KernelMemory: kernelMemory,
MemoryLimit: true,
SwapLimit: swapLimit,
MemoryReservation: memoryReservation,
OomKillDisable: oomKillDisable,
MemorySwappiness: memorySwappiness,
KernelMemory: kernelMemory,
}
}