Skip to content

Commit 2627721

Browse files
authored
Merge pull request #3917 from jaininshah9/master
changing the formula to correctly pass the CPUQota to docker
2 parents 0384631 + 9752e08 commit 2627721

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

client/driver/docker.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -1138,9 +1138,13 @@ func (d *DockerDriver) createContainerConfig(ctx *ExecContext, task *structs.Tas
11381138
}
11391139

11401140
// Calculate CPU Quota
1141+
// cfs_quota_us is the time per core, so we must
1142+
// multiply the time by the number of cores available
1143+
// See https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/resource_management_guide/sec-cpu
11411144
if driverConfig.CPUHardLimit {
1145+
numCores := runtime.NumCPU()
11421146
percentTicks := float64(task.Resources.CPU) / float64(d.node.Resources.CPU)
1143-
hostConfig.CPUQuota = int64(percentTicks * defaultCFSPeriodUS)
1147+
hostConfig.CPUQuota = int64(percentTicks*defaultCFSPeriodUS) * int64(numCores)
11441148
}
11451149

11461150
// Windows does not support MemorySwap/MemorySwappiness #2193

0 commit comments

Comments
 (0)