summaryrefslogtreecommitdiffhomepage
path: root/runsc/sandbox
diff options
context:
space:
mode:
authorAleksandr Razumov <a.razumov@corp.mail.ru>2019-12-17 13:06:42 +0300
committerAleksandr Razumov <a.razumov@corp.mail.ru>2019-12-17 13:27:13 +0300
commitb661434202672f920291bf5685b68772103c66cb (patch)
treeb242497f07ca106a2600910a5cd8b8ff865b23ca /runsc/sandbox
parent8782f0e287df2a2fd9f9dfb3f0e1589cc15a4f91 (diff)
Add minimum CPU number and only lower CPUs on --cpu-num-from-quota
* Add `--cpu-num-min` flag to control minimum CPUs * Only lower CPU count * Fix comments
Diffstat (limited to 'runsc/sandbox')
-rw-r--r--runsc/sandbox/sandbox.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/runsc/sandbox/sandbox.go b/runsc/sandbox/sandbox.go
index cbfb873d1..f6feadf75 100644
--- a/runsc/sandbox/sandbox.go
+++ b/runsc/sandbox/sandbox.go
@@ -637,8 +637,14 @@ func (s *Sandbox) createSandboxProcess(conf *boot.Config, args *Args, startSyncF
if err != nil {
return fmt.Errorf("getting cpu qouta from cgroups: %v", err)
}
- if quota > 0 {
- cpuNum = int(math.Ceil(quota))
+ if n := int(math.Ceil(quota)); n > 0 {
+ if n < conf.CPUNumMin {
+ n = conf.CPUNumMin
+ }
+ if n < cpuNum {
+ // Only lower the cpu number.
+ cpuNum = n
+ }
}
}
cmd.Args = append(cmd.Args, "--cpu-num", strconv.Itoa(cpuNum))