Skip to content

Commit

Permalink
Merge pull request #15728 from tyler92/fix-cpu-millis-limit
Browse files Browse the repository at this point in the history
Fix CPU usage limitation in play kube for non integer values
  • Loading branch information
openshift-merge-robot authored Sep 10, 2022
2 parents 2d8417d + b8108d0 commit b9cbc0c
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions pkg/specgen/generate/kube/kube.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit b9cbc0c

Please sign in to comment.