Skip to content

Commit

Permalink
Merge pull request #73342 from szuecs/fix/period-not-reset-if-gate-no…
Browse files Browse the repository at this point in the history
…t-set

cpuPeriod was not reset
  • Loading branch information
k8s-ci-robot committed Feb 12, 2019
2 parents 73dc138 + fd0cff9 commit c9964aa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
8 changes: 0 additions & 8 deletions pkg/kubelet/kuberuntime/helpers_linux.go
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion pkg/kubelet/kuberuntime/kuberuntime_container_linux.go
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c9964aa

Please sign in to comment.