Skip to content

Commit 7ca6184

Browse files
Furistoroboquat
authored andcommitted
Log parent quota
1 parent 0943c1d commit 7ca6184

File tree

1 file changed

+12
-1
lines changed
  • components/ws-daemon/pkg/cpulimit

1 file changed

+12
-1
lines changed

components/ws-daemon/pkg/cpulimit/cfs.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,22 @@ func (basePath CgroupCFSController) SetLimit(limit Bandwidth) (changed bool, err
5252

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

61+
func (basePath CgroupCFSController) readParentQuota() time.Duration {
62+
parent := CgroupCFSController(filepath.Dir(string(basePath)))
63+
pq, err := parent.readUint64("cpu.cfs_quota_us")
64+
if err != nil {
65+
return time.Duration(0)
66+
}
67+
68+
return time.Duration(pq) * time.Microsecond
69+
}
70+
6071
func (basePath CgroupCFSController) readUint64(path string) (uint64, error) {
6172
fn := filepath.Join(string(basePath), path)
6273
fc, err := os.ReadFile(fn)

0 commit comments

Comments
 (0)