Merge pull request #15728 from tyler92/fix-cpu-millis-limit
Fix CPU usage limitation in play kube for non integer values
This commit is contained in:
commit
b9cbc0c09a
|
@ -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: "a,
|
Quota: "a,
|
||||||
Period: &period,
|
Period: &period,
|
||||||
|
|
Loading…
Reference in New Issue