Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c9964aa

Browse files
authored
Merge pull request kubernetes#73342 from szuecs/fix/period-not-reset-if-gate-not-set
cpuPeriod was not reset
2 parents 73dc138 + fd0cff9 commit c9964aa

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

pkg/kubelet/kuberuntime/helpers_linux.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ limitations under the License.
1818

1919
package kuberuntime
2020

21-
import (
22-
utilfeature "k8s.io/apiserver/pkg/util/feature"
23-
kubefeatures "k8s.io/kubernetes/pkg/features"
24-
)
25-
2621
const (
2722
// Taken from lmctfy https://github.com/google/lmctfy/blob/master/lmctfy/controllers/cpu_controller.cc
2823
minShares = 2
@@ -59,9 +54,6 @@ func milliCPUToQuota(milliCPU int64, period int64) (quota int64) {
5954
if milliCPU == 0 {
6055
return
6156
}
62-
if !utilfeature.DefaultFeatureGate.Enabled(kubefeatures.CPUCFSQuotaPeriod) {
63-
period = quotaPeriod
64-
}
6557

6658
// we then convert your milliCPU to a value normalized over a period
6759
quota = (milliCPU * period) / milliCPUToCPU

pkg/kubelet/kuberuntime/kuberuntime_container_linux.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import (
2222
"time"
2323

2424
"k8s.io/api/core/v1"
25+
utilfeature "k8s.io/apiserver/pkg/util/feature"
26+
kubefeatures "k8s.io/kubernetes/pkg/features"
2527
runtimeapi "k8s.io/kubernetes/pkg/kubelet/apis/cri/runtime/v1alpha2"
2628
"k8s.io/kubernetes/pkg/kubelet/qos"
2729
)
@@ -67,7 +69,10 @@ func (m *kubeGenericRuntimeManager) generateLinuxContainerConfig(container *v1.C
6769
if m.cpuCFSQuota {
6870
// if cpuLimit.Amount is nil, then the appropriate default value is returned
6971
// to allow full usage of cpu resource.
70-
cpuPeriod := int64(m.cpuCFSQuotaPeriod.Duration / time.Microsecond)
72+
cpuPeriod := int64(quotaPeriod)
73+
if utilfeature.DefaultFeatureGate.Enabled(kubefeatures.CPUCFSQuotaPeriod) {
74+
cpuPeriod = int64(m.cpuCFSQuotaPeriod.Duration / time.Microsecond)
75+
}
7176
cpuQuota := milliCPUToQuota(cpuLimit.MilliValue(), cpuPeriod)
7277
lc.Resources.CpuQuota = cpuQuota
7378
lc.Resources.CpuPeriod = cpuPeriod

0 commit comments

Comments
 (0)