diff options
author | Aleksandr Razumov <a.razumov@corp.mail.ru> | 2019-12-17 13:06:42 +0300 |
---|---|---|
committer | Aleksandr Razumov <a.razumov@corp.mail.ru> | 2019-12-17 13:27:13 +0300 |
commit | b661434202672f920291bf5685b68772103c66cb (patch) | |
tree | b242497f07ca106a2600910a5cd8b8ff865b23ca /runsc/sandbox/sandbox.go | |
parent | 8782f0e287df2a2fd9f9dfb3f0e1589cc15a4f91 (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/sandbox.go')
-rw-r--r-- | runsc/sandbox/sandbox.go | 10 |
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)) |