mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-04 10:47:25 +00:00
Set minimal shares for containers with no cpu specified
This commit is contained in:
@@ -306,8 +306,10 @@ func ConnectToDockerOrDie(dockerEndpoint string) DockerInterface {
|
|||||||
|
|
||||||
func milliCPUToShares(milliCPU int64) int64 {
|
func milliCPUToShares(milliCPU int64) int64 {
|
||||||
if milliCPU == 0 {
|
if milliCPU == 0 {
|
||||||
// zero milliCPU means unset. Use kernel default.
|
// Docker converts zero milliCPU to unset, which maps to kernel default
|
||||||
return 0
|
// 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.
|
// Conceptually (milliCPU / milliCPUToCPU) * sharesPerCPU, but factored to improve rounding.
|
||||||
shares := (milliCPU * sharesPerCPU) / milliCPUToCPU
|
shares := (milliCPU * sharesPerCPU) / milliCPUToCPU
|
||||||
|
Reference in New Issue
Block a user