summaryrefslogtreecommitdiff
path: root/pkg/domain/infra
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-11-02 16:02:55 +0100
committerGitHub <noreply@github.com>2020-11-02 16:02:55 +0100
commit7375a55757fe7615f133db5b097bb4db9a244888 (patch)
tree6d29d221f696c3aabfa1e847d92f55da41cb27e9 /pkg/domain/infra
parent8bc0f51e330185bed1be4bcfffd04729b4bc9cd4 (diff)
parent03579649063d669f9f57d534f74136befef98c62 (diff)
downloadpodman-7375a55757fe7615f133db5b097bb4db9a244888.tar.gz
podman-7375a55757fe7615f133db5b097bb4db9a244888.tar.bz2
podman-7375a55757fe7615f133db5b097bb4db9a244888.zip
Merge pull request #8207 from xordspar0/common-period-quota
Centralize cores and period/quota conversion code
Diffstat (limited to 'pkg/domain/infra')
-rw-r--r--pkg/domain/infra/abi/play.go9
1 files changed, 3 insertions, 6 deletions
diff --git a/pkg/domain/infra/abi/play.go b/pkg/domain/infra/abi/play.go
index 57de0f3b1..fbba00984 100644
--- a/pkg/domain/infra/abi/play.go
+++ b/pkg/domain/infra/abi/play.go
@@ -36,8 +36,6 @@ const (
kubeDirectoryPermission = 0755
// https://kubernetes.io/docs/concepts/storage/volumes/#hostpath
kubeFilePermission = 0644
- // Kubernetes sets CPUPeriod to 100000us (100ms): https://kubernetes.io/docs/reference/command-line-tools-reference/kubelet/
- defaultCPUPeriod = 100000
)
func (ic *ContainerEngine) PlayKube(ctx context.Context, path string, options entities.PlayKubeOptions) (*entities.PlayKubeReport, error) {
@@ -515,10 +513,9 @@ func kubeContainerToCreateConfig(ctx context.Context, containerYAML v1.Container
return nil, errors.Wrap(err, "Failed to set CPU quota")
}
if milliCPU > 0 {
- containerConfig.Resources.CPUPeriod = defaultCPUPeriod
- // CPU quota is a fraction of the period: milliCPU / 1000.0 * period
- // Or, without floating point math:
- containerConfig.Resources.CPUQuota = milliCPU * defaultCPUPeriod / 1000
+ period, quota := util.CoresToPeriodAndQuota(float64(milliCPU) / 1000)
+ containerConfig.Resources.CPUPeriod = period
+ containerConfig.Resources.CPUQuota = quota
}
containerConfig.Resources.Memory, err = quantityToInt64(containerYAML.Resources.Limits.Memory())