summaryrefslogtreecommitdiff
path: root/pkg/specgen
diff options
context:
space:
mode:
authorMikhail Khachayants <tyler92@inbox.ru>2022-09-09 21:39:37 +0300
committerMikhail Khachayants <tyler92@inbox.ru>2022-09-10 10:53:50 +0300
commitb8108d06b431018b4022879a2504a44ee95e6911 (patch)
tree0bde84caeb2c8e4cb2ff0ad3d2d8ca9ec185372d /pkg/specgen
parent94864cbce6e758552c853999951681bfdef93b18 (diff)
downloadpodman-b8108d06b431018b4022879a2504a44ee95e6911.tar.gz
podman-b8108d06b431018b4022879a2504a44ee95e6911.tar.bz2
podman-b8108d06b431018b4022879a2504a44ee95e6911.zip
Fix CPU usage limitation in play kube for non integer values
This logic has been broken by commit 9c6c981928c3e020ff6eef9454c7ee86aa8c83d1 (kube: fix conversion from milliCPU to period/quota). [NO NEW TESTS NEEDED] Fixes: #15726 Signed-off-by: Mikhail Khachayants <tyler92@inbox.ru>
Diffstat (limited to 'pkg/specgen')
-rw-r--r--pkg/specgen/generate/kube/kube.go7
1 files changed, 2 insertions, 5 deletions
diff --git a/pkg/specgen/generate/kube/kube.go b/pkg/specgen/generate/kube/kube.go
index 9fd0adecf..7d85fd2f3 100644
--- a/pkg/specgen/generate/kube/kube.go
+++ b/pkg/specgen/generate/kube/kube.go
@@ -207,12 +207,9 @@ func ToSpecGen(ctx context.Context, opts *CtrSpecGenOptions) (*specgen.SpecGener
s.SeccompProfilePath = opts.SeccompPaths.FindForContainer(opts.Container.Name)
s.ResourceLimits = &spec.LinuxResources{}
- milliCPU, err := quantityToInt64(opts.Container.Resources.Limits.Cpu())
- if err != nil {
- return nil, fmt.Errorf("failed to set CPU quota: %w", err)
- }
+ milliCPU := opts.Container.Resources.Limits.Cpu().MilliValue()
if milliCPU > 0 {
- period, quota := util.CoresToPeriodAndQuota(float64(milliCPU))
+ period, quota := util.CoresToPeriodAndQuota(float64(milliCPU) / 1000)
s.ResourceLimits.CPU = &spec.LinuxCPU{
Quota: &quota,
Period: &period,