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>
This commit is contained in:
Mikhail Khachayants
2022-09-09 21:39:37 +03:00
parent 94864cbce6
commit b8108d06b4

View File

@ -207,12 +207,9 @@ func ToSpecGen(ctx context.Context, opts *CtrSpecGenOptions) (*specgen.SpecGener
s.SeccompProfilePath = opts.SeccompPaths.FindForContainer(opts.Container.Name) s.SeccompProfilePath = opts.SeccompPaths.FindForContainer(opts.Container.Name)
s.ResourceLimits = &spec.LinuxResources{} s.ResourceLimits = &spec.LinuxResources{}
milliCPU, err := quantityToInt64(opts.Container.Resources.Limits.Cpu()) milliCPU := opts.Container.Resources.Limits.Cpu().MilliValue()
if err != nil {
return nil, fmt.Errorf("failed to set CPU quota: %w", err)
}
if milliCPU > 0 { if milliCPU > 0 {
period, quota := util.CoresToPeriodAndQuota(float64(milliCPU)) period, quota := util.CoresToPeriodAndQuota(float64(milliCPU) / 1000)
s.ResourceLimits.CPU = &spec.LinuxCPU{ s.ResourceLimits.CPU = &spec.LinuxCPU{
Quota: &quota, Quota: &quota,
Period: &period, Period: &period,