Skip to content

Commit d415765

Browse files
mykola-kobets-epamal1img
authored andcommitted
[launcher] Fix minimal cpu quota
Signed-off-by: Mykola Kobets <mykola_kobets@epam.com>
1 parent d0d0c4c commit d415765

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

launcher/spec.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ import (
4646
* Consts
4747
**********************************************************************************************************************/
4848

49-
const defaultCPUPeriod uint64 = 100000
49+
const (
50+
defaultCPUPeriod uint64 = 100000
51+
minCPUQuota int64 = 1000
52+
)
5053

5154
const cgroupsPath = "/system.slice/system-aos\\x2dservice.slice/"
5255

@@ -116,7 +119,11 @@ func (spec *runtimeSpec) setCPULimit(cpuLimit uint64) {
116119
}
117120

118121
cpuPeriod := defaultCPUPeriod
122+
119123
cpuQuota := int64(cpuLimit * defaultCPUPeriod * uint64(runtime.NumCPU()) / spec.nodeInfo.MaxDMIPs)
124+
if cpuQuota < minCPUQuota {
125+
cpuQuota = minCPUQuota
126+
}
120127

121128
spec.ociSpec.Linux.Resources.CPU.Period = &cpuPeriod
122129
spec.ociSpec.Linux.Resources.CPU.Quota = &cpuQuota

0 commit comments

Comments
 (0)