From b041fdc0d53c209a5e0614d2b35c6fa2209fe12d Mon Sep 17 00:00:00 2001 From: Qiang Huang Date: Fri, 18 Mar 2016 11:16:53 +0800 Subject: [PATCH] Add validation for cpu period and quota Accoding to: https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt It has minimal and maximal limit. Signed-off-by: Qiang Huang --- daemon/daemon_unix.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/daemon/daemon_unix.go b/daemon/daemon_unix.go index b6e60ff77c..e2e6f7a5c1 100644 --- a/daemon/daemon_unix.go +++ b/daemon/daemon_unix.go @@ -393,11 +393,17 @@ func verifyContainerResources(resources *containertypes.Resources, sysInfo *sysi logrus.Warnf("Your kernel does not support CPU cfs period. Period discarded.") resources.CPUPeriod = 0 } + if resources.CPUPeriod > 0 && (resources.CPUPeriod < 1000 || resources.CPUQuota > 1000000) { + return warnings, fmt.Errorf("CPU cfs period can not be less than 1ms (i.e. 1000) or larger than 1s (i.e. 1000000)") + } if resources.CPUQuota > 0 && !sysInfo.CPUCfsQuota { warnings = append(warnings, "Your kernel does not support CPU cfs quota. Quota discarded.") logrus.Warnf("Your kernel does not support CPU cfs quota. Quota discarded.") resources.CPUQuota = 0 } + if resources.CPUQuota > 0 && resources.CPUQuota < 1000 { + return warnings, fmt.Errorf("CPU cfs quota can not be less than 1ms (i.e. 1000)") + } // cpuset subsystem checks and adjustments if (resources.CpusetCpus != "" || resources.CpusetMems != "") && !sysInfo.Cpuset {