Merge pull request #10736 from coolljt0725/add_cpu_limit

Add support cpu cfs_quota
This commit is contained in:
Jessie Frazelle 2015-04-20 17:55:01 -07:00
commit 1b9b5095ac

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