From 6e01e1c8ae288ede8a2bcb55b63295473a4abf87 Mon Sep 17 00:00:00 2001 From: Alex Dadgar Date: Mon, 19 Oct 2015 11:28:05 -0700 Subject: [PATCH] Check for invalid CPU limit for cgroups --- client/executor/exec_linux.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client/executor/exec_linux.go b/client/executor/exec_linux.go index 588659dfc..c97ce963b 100644 --- a/client/executor/exec_linux.go +++ b/client/executor/exec_linux.go @@ -196,6 +196,10 @@ func (e *LinuxExecutor) configureCgroups(resources *structs.Resources) error { } if resources.CPU > 0.0 { + if resources.CPU < 2.0 { + return fmt.Errorf("resources.CPU must be equal to or greater than 2.0: %v", resources.CPU) + } + // Set the relative CPU shares for this cgroup. // The simplest scale is 1 share to 1 MHz so 1024 = 1GHz. This means any // given process will have at least that amount of resources, but likely