From fd0cff9c776da42b6364de39b6e8c694bd90fd38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandor=20Sz=C3=BCcs?= Date: Sat, 26 Jan 2019 09:36:29 +0100 Subject: [PATCH] fix #73264 cpuPeriod was not reset, but used as it is if alpha gate is disabled MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Sandor Szücs --- pkg/kubelet/kuberuntime/helpers_linux.go | 8 -------- pkg/kubelet/kuberuntime/kuberuntime_container_linux.go | 7 ++++++- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/pkg/kubelet/kuberuntime/helpers_linux.go b/pkg/kubelet/kuberuntime/helpers_linux.go index b6a4f4f85c9..204bc4e9ffb 100644 --- a/pkg/kubelet/kuberuntime/helpers_linux.go +++ b/pkg/kubelet/kuberuntime/helpers_linux.go @@ -18,11 +18,6 @@ limitations under the License. package kuberuntime -import ( - utilfeature "k8s.io/apiserver/pkg/util/feature" - kubefeatures "k8s.io/kubernetes/pkg/features" -) - const ( // Taken from lmctfy https://github.com/google/lmctfy/blob/master/lmctfy/controllers/cpu_controller.cc minShares = 2 @@ -59,9 +54,6 @@ func milliCPUToQuota(milliCPU int64, period int64) (quota int64) { if milliCPU == 0 { return } - if !utilfeature.DefaultFeatureGate.Enabled(kubefeatures.CPUCFSQuotaPeriod) { - period = quotaPeriod - } // we then convert your milliCPU to a value normalized over a period quota = (milliCPU * period) / milliCPUToCPU diff --git a/pkg/kubelet/kuberuntime/kuberuntime_container_linux.go b/pkg/kubelet/kuberuntime/kuberuntime_container_linux.go index c5da7e3171d..1a6a50311c0 100644 --- a/pkg/kubelet/kuberuntime/kuberuntime_container_linux.go +++ b/pkg/kubelet/kuberuntime/kuberuntime_container_linux.go @@ -22,6 +22,8 @@ import ( "time" "k8s.io/api/core/v1" + utilfeature "k8s.io/apiserver/pkg/util/feature" + kubefeatures "k8s.io/kubernetes/pkg/features" runtimeapi "k8s.io/kubernetes/pkg/kubelet/apis/cri/runtime/v1alpha2" "k8s.io/kubernetes/pkg/kubelet/qos" ) @@ -67,7 +69,10 @@ func (m *kubeGenericRuntimeManager) generateLinuxContainerConfig(container *v1.C if m.cpuCFSQuota { // if cpuLimit.Amount is nil, then the appropriate default value is returned // to allow full usage of cpu resource. - cpuPeriod := int64(m.cpuCFSQuotaPeriod.Duration / time.Microsecond) + cpuPeriod := int64(quotaPeriod) + if utilfeature.DefaultFeatureGate.Enabled(kubefeatures.CPUCFSQuotaPeriod) { + cpuPeriod = int64(m.cpuCFSQuotaPeriod.Duration / time.Microsecond) + } cpuQuota := milliCPUToQuota(cpuLimit.MilliValue(), cpuPeriod) lc.Resources.CpuQuota = cpuQuota lc.Resources.CpuPeriod = cpuPeriod