Merge pull request #93248 from giuseppe/cgroup-set-max-shares

kubelet: clamp cpu.shares to max allowed
This commit is contained in:
Kubernetes Prow Robot 2020-07-20 19:51:14 -07:00 committed by GitHub
commit c09ecf13a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -38,8 +38,11 @@ import (
)
const (
// Taken from lmctfy https://github.com/google/lmctfy/blob/master/lmctfy/controllers/cpu_controller.cc
MinShares = 2
// These limits are defined in the kernel:
// https://github.com/torvalds/linux/blob/0bddd227f3dc55975e2b8dfa7fc6f959b062a2c7/kernel/sched/sched.h#L427-L428
MinShares = 2
MaxShares = 262144
SharesPerCPU = 1024
MilliCPUToCPU = 1000
@ -88,6 +91,9 @@ func MilliCPUToShares(milliCPU int64) uint64 {
if shares < MinShares {
return MinShares
}
if shares > MaxShares {
return MaxShares
}
return uint64(shares)
}