From 8a60a1e14a5e98b7ed0fbea57369615a766a1ae9 Mon Sep 17 00:00:00 2001 From: Olly Pomeroy Date: Wed, 8 May 2019 09:30:06 +0000 Subject: [PATCH] Switch swarmmode services to NanoCpu Today `$ docker service create --limit-cpu` configures a containers `CpuPeriod` and `CpuQuota` variables, this commit switches this to configure a containers `NanoCpu` variable instead. Signed-off-by: Olly Pomeroy --- daemon/cluster/executor/container/container.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/daemon/cluster/executor/container/container.go b/daemon/cluster/executor/container/container.go index abbd6bfb11..a768d9d614 100644 --- a/daemon/cluster/executor/container/container.go +++ b/daemon/cluster/executor/container/container.go @@ -6,7 +6,6 @@ import ( "net" "strconv" "strings" - "time" "github.com/sirupsen/logrus" @@ -31,10 +30,6 @@ import ( ) const ( - // Explicitly use the kernel's default setting for CPU quota of 100ms. - // https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt - cpuQuotaPeriod = 100 * time.Millisecond - // systemLabelPrefix represents the reserved namespace for system labels. systemLabelPrefix = "com.docker.swarm" ) @@ -451,9 +446,7 @@ func (c *containerConfig) resources() enginecontainer.Resources { } if r.Limits.NanoCPUs > 0 { - // CPU Period must be set in microseconds. - resources.CPUPeriod = int64(cpuQuotaPeriod / time.Microsecond) - resources.CPUQuota = r.Limits.NanoCPUs * resources.CPUPeriod / 1e9 + resources.NanoCPUs = r.Limits.NanoCPUs } return resources