Skip to content

Commit

Permalink
Set minimal shares for containers with no cpu specified
Browse files Browse the repository at this point in the history
  • Loading branch information
dchen1107 committed Jul 2, 2015
1 parent 3597344 commit 4b85e02
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/kubelet/dockertools/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,10 @@ func ConnectToDockerOrDie(dockerEndpoint string) DockerInterface {

func milliCPUToShares(milliCPU int64) int64 {
if milliCPU == 0 {
// zero milliCPU means unset. Use kernel default.
return 0
// Docker converts zero milliCPU to unset, which maps to kernel default
// for unset: 1024. Return 2 here to really match kernel default for
// zero milliCPU.
return 2
}
// Conceptually (milliCPU / milliCPUToCPU) * sharesPerCPU, but factored to improve rounding.
shares := (milliCPU * sharesPerCPU) / milliCPUToCPU
Expand Down

0 comments on commit 4b85e02

Please sign in to comment.