Add support cpu cfs quota

Signed-off-by: Lei Jitang <leijitang@huawei.com>
Upstream-commit: dcc50e1d593fd7995189872791c6d7a013f16970
Component: engine
This commit is contained in:
Lei Jitang
2015-04-20 08:16:47 -07:00
parent 5f9567a9e8
commit f8f4bcdb38
15 changed files with 84 additions and 0 deletions

View File

@ -13,6 +13,7 @@ import (
type SysInfo struct {
MemoryLimit bool
SwapLimit bool
CpuCfsQuota bool
IPv4ForwardingDisabled bool
AppArmor bool
}
@ -39,6 +40,19 @@ func New(quiet bool) *SysInfo {
}
}
if cgroupCpuMountpoint, err := cgroups.FindCgroupMountpoint("cpu"); err != nil {
if !quiet {
logrus.Warnf("WARING: %s\n", err)
}
} else {
_, err1 := ioutil.ReadFile(path.Join(cgroupCpuMountpoint, "cpu.cfs_quota_us"))
logrus.Warnf("%s", cgroupCpuMountpoint)
sysInfo.CpuCfsQuota = err1 == nil
if !sysInfo.CpuCfsQuota && !quiet {
logrus.Warnf("WARING: Your kernel does not support cgroup cfs quotas")
}
}
// Check if AppArmor is supported.
if _, err := os.Stat("/sys/kernel/security/apparmor"); os.IsNotExist(err) {
sysInfo.AppArmor = false