Skip to content

Commit

Permalink
ws-daemon: Returns no limit if cpu.max does not exist.
Browse files Browse the repository at this point in the history
Signed-off-by: utam0k <k0ma@utam0k.jp>
  • Loading branch information
utam0k committed Aug 24, 2022
1 parent 91fa12d commit e15d433
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion components/ws-daemon/pkg/iws/iws.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package iws
import (
"bytes"
"context"
"errors"
"fmt"
"io"
"math"
Expand Down Expand Up @@ -1104,13 +1105,16 @@ func getCpuResourceInfoV2(mountPoint, cgroupPath string) (*api.Cpu, error) {
used := cpuUsage / totalTime * 1000

quota, period, err := cpu.Max()
if err != nil {
if errors.Is(err, os.ErrNotExist) {
quota = math.MaxUint64
} else if err != nil {
return nil, err
}

// if no cpu limit has been specified, use the number of cores
var limit uint64
if quota == math.MaxUint64 {
// TODO(toru): we have to check a parent cgroup instead of a host resources
cpuInfo, err := linuxproc.ReadCPUInfo("/proc/cpuinfo")
if err != nil {
return nil, err
Expand Down

0 comments on commit e15d433

Please sign in to comment.