Merge pull request #3917 from jaininshah9/master

changing the formula to correctly pass the CPUQota to docker
This commit is contained in:
Michael Schurter 2018-02-28 20:00:37 -08:00 committed by GitHub
commit 557a70f78d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1138,9 +1138,13 @@ func (d *DockerDriver) createContainerConfig(ctx *ExecContext, task *structs.Tas
}
// Calculate CPU Quota
// cfs_quota_us is the time per core, so we must
// multiply the time by the number of cores available
// See https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/resource_management_guide/sec-cpu
if driverConfig.CPUHardLimit {
numCores := runtime.NumCPU()
percentTicks := float64(task.Resources.CPU) / float64(d.node.Resources.CPU)
hostConfig.CPUQuota = int64(percentTicks * defaultCFSPeriodUS)
hostConfig.CPUQuota = int64(percentTicks*defaultCFSPeriodUS) * int64(numCores)
}
// Windows does not support MemorySwap/MemorySwappiness #2193