Skip to content

Commit

Permalink
Merge pull request #3917 from jaininshah9/master
Browse files Browse the repository at this point in the history
changing the formula to correctly pass the CPUQota to docker
  • Loading branch information
schmichael committed Mar 1, 2018
2 parents 0384631 + 9752e08 commit 2627721
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion client/driver/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2627721

Please sign in to comment.