Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion components/ws-daemon/pkg/cpulimit/cfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,22 @@ func (basePath CgroupCFSController) SetLimit(limit Bandwidth) (changed bool, err

err = os.WriteFile(filepath.Join(string(basePath), "cpu.cfs_quota_us"), []byte(strconv.FormatInt(target.Microseconds(), 10)), 0644)
if err != nil {
return false, xerrors.Errorf("cannot set CFS quota of %d (period is %d): %w", target.Microseconds(), period.Microseconds(), err)
return false, xerrors.Errorf("cannot set CFS quota of %d (period is %d, parent quota is %d): %w",
target.Microseconds(), period.Microseconds(), basePath.readParentQuota().Microseconds(), err)
}
return true, nil
}

func (basePath CgroupCFSController) readParentQuota() time.Duration {
parent := CgroupCFSController(filepath.Dir(string(basePath)))
pq, err := parent.readUint64("cpu.cfs_quota_us")
if err != nil {
return time.Duration(0)
}

return time.Duration(pq) * time.Microsecond
}

func (basePath CgroupCFSController) readUint64(path string) (uint64, error) {
fn := filepath.Join(string(basePath), path)
fc, err := os.ReadFile(fn)
Expand Down