Merge pull request #111554 from paskal/paskal/clarify_default_cfs_period

Clarify cpu.cfs_period_us default value
This commit is contained in:
Kubernetes Prow Robot 2022-08-25 07:28:07 -07:00 committed by GitHub
commit 2b5475b3fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 9 deletions

View File

@ -59,7 +59,7 @@ var (
RegistryPullQPS: 5, RegistryPullQPS: 5,
HairpinMode: kubeletconfig.PromiscuousBridge, HairpinMode: kubeletconfig.PromiscuousBridge,
NodeLeaseDurationSeconds: 1, NodeLeaseDurationSeconds: 1,
CPUCFSQuotaPeriod: metav1.Duration{Duration: 25 * time.Millisecond}, CPUCFSQuotaPeriod: metav1.Duration{Duration: 25 * time.Microsecond},
TopologyManagerScope: kubeletconfig.PodTopologyManagerScope, TopologyManagerScope: kubeletconfig.PodTopologyManagerScope,
TopologyManagerPolicy: kubeletconfig.SingleNumaNodeTopologyManagerPolicy, TopologyManagerPolicy: kubeletconfig.SingleNumaNodeTopologyManagerPolicy,
ShutdownGracePeriod: metav1.Duration{Duration: 30 * time.Second}, ShutdownGracePeriod: metav1.Duration{Duration: 30 * time.Second},
@ -145,10 +145,10 @@ func TestValidateKubeletConfiguration(t *testing.T) {
name: "specify CPUCFSQuotaPeriod without enabling CPUCFSQuotaPeriod", name: "specify CPUCFSQuotaPeriod without enabling CPUCFSQuotaPeriod",
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration { configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
conf.FeatureGates = map[string]bool{"CustomCPUCFSQuotaPeriod": false} conf.FeatureGates = map[string]bool{"CustomCPUCFSQuotaPeriod": false}
conf.CPUCFSQuotaPeriod = metav1.Duration{Duration: 200 * time.Millisecond} conf.CPUCFSQuotaPeriod = metav1.Duration{Duration: 200 * time.Microsecond}
return conf return conf
}, },
errMsg: "invalid configuration: cpuCFSQuotaPeriod (--cpu-cfs-quota-period) {200ms} requires feature gate CustomCPUCFSQuotaPeriod", errMsg: "invalid configuration: cpuCFSQuotaPeriod (--cpu-cfs-quota-period) {200µs} requires feature gate CustomCPUCFSQuotaPeriod",
}, },
{ {
name: "invalid CPUCFSQuotaPeriod", name: "invalid CPUCFSQuotaPeriod",

View File

@ -44,7 +44,7 @@ const (
SharesPerCPU = 1024 SharesPerCPU = 1024
MilliCPUToCPU = 1000 MilliCPUToCPU = 1000
// 100000 is equivalent to 100ms // 100000 is equivalent to 100usec
QuotaPeriod = 100000 QuotaPeriod = 100000
MinQuotaPeriod = 1000 MinQuotaPeriod = 1000
) )
@ -52,8 +52,8 @@ const (
// MilliCPUToQuota converts milliCPU to CFS quota and period values. // MilliCPUToQuota converts milliCPU to CFS quota and period values.
func MilliCPUToQuota(milliCPU int64, period int64) (quota int64) { func MilliCPUToQuota(milliCPU int64, period int64) (quota int64) {
// CFS quota is measured in two values: // CFS quota is measured in two values:
// - cfs_period_us=100ms (the amount of time to measure usage across given by period) // - cfs_period_us=100usec (the amount of time to measure usage across given by period)
// - cfs_quota=20ms (the amount of cpu time allowed to be used across a period) // - cfs_quota=20usec (the amount of cpu time allowed to be used across a period)
// so in the above example, you are limited to 20% of a single CPU // so in the above example, you are limited to 20% of a single CPU
// for multi-cpu environments, you just scale equivalent amounts // for multi-cpu environments, you just scale equivalent amounts
// see https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt for details // see https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt for details

View File

@ -22,7 +22,7 @@ package kuberuntime
const ( const (
milliCPUToCPU = 1000 milliCPUToCPU = 1000
// 100000 is equivalent to 100ms // 100000 is equivalent to 100usec
quotaPeriod = 100000 quotaPeriod = 100000
minQuotaPeriod = 1000 minQuotaPeriod = 1000
) )
@ -30,8 +30,8 @@ const (
// milliCPUToQuota converts milliCPU to CFS quota and period values // milliCPUToQuota converts milliCPU to CFS quota and period values
func milliCPUToQuota(milliCPU int64, period int64) (quota int64) { func milliCPUToQuota(milliCPU int64, period int64) (quota int64) {
// CFS quota is measured in two values: // CFS quota is measured in two values:
// - cfs_period_us=100ms (the amount of time to measure usage across) // - cfs_period_us=100usec (the amount of time to measure usage across given by period)
// - cfs_quota=20ms (the amount of cpu time allowed to be used across a period) // - cfs_quota=20usec (the amount of cpu time allowed to be used across a period)
// so in the above example, you are limited to 20% of a single CPU // so in the above example, you are limited to 20% of a single CPU
// for multi-cpu environments, you just scale equivalent amounts // for multi-cpu environments, you just scale equivalent amounts
// see https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt for details // see https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt for details