diff options
author | Jordan Christiansen <xordspar0@gmail.com> | 2020-10-31 09:32:52 -0500 |
---|---|---|
committer | Jordan Christiansen <xordspar0@gmail.com> | 2020-10-31 10:07:11 -0500 |
commit | 03579649063d669f9f57d534f74136befef98c62 (patch) | |
tree | 3b2d9d5e5e52c46c53d6e5b9c439f26067f9a0b2 /pkg/domain | |
parent | 2aaa036f560e2c42ebb033869eeef539dbc47fef (diff) | |
download | podman-03579649063d669f9f57d534f74136befef98c62.tar.gz podman-03579649063d669f9f57d534f74136befef98c62.tar.bz2 podman-03579649063d669f9f57d534f74136befef98c62.zip |
Centralize cores and period/quota conversion code
Signed-off-by: Jordan Christiansen <xordspar0@gmail.com>
Diffstat (limited to 'pkg/domain')
-rw-r--r-- | pkg/domain/infra/abi/play.go | 9 |
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()) |