Browse Source

Allow to limit cgroup cpu shares

Related-bug: #1755605

Change-Id: I1f24866ea2ec01e3ef22571145efa25ab219bb3a
Signed-off-by: Bogdan Dobrelya <bdobreli@redhat.com>
(cherry picked from commit 4a4f43ac36)
changes/64/701064/1
Bogdan Dobrelya 1 year ago
parent
commit
2ddf40d833
3 changed files with 9 additions and 0 deletions
  1. +2
    -0
      paunch/builder/compose1.py
  2. +2
    -0
      paunch/tests/test_builder_compose1.py
  3. +5
    -0
      releasenotes/notes/cgroups-cpu-shares-038ced471b862b4e.yaml

+ 2
- 0
paunch/builder/compose1.py View File

@@ -188,6 +188,8 @@ class ComposeV1Builder(object):
cmd.append('--volumes-from=%s' % v)
if 'log_tag' in cconfig:
cmd.append('--log-opt=tag=%s' % cconfig['log_tag'])
if 'cpu_shares' in cconfig:
cmd.append('--cpu-shares=%s' % cconfig['cpu_shares'])
if 'security_opt' in cconfig:
cmd.append('--security-opt=%s' % cconfig['security_opt'])
if 'cpuset_cpus' in cconfig:

+ 2
- 0
paunch/tests/test_builder_compose1.py View File

@@ -434,6 +434,7 @@ three-12345678 three''', '', 0),
},
'env_file': '/tmp/foo.env',
'log_tag': '{{.ImageName}}/{{.Name}}/{{.ID}}',
'cpu_shares': 600,
'security_opt': 'label:disable',
'mem_limit': '1G',
'memswap_limit': '1G',
@@ -452,6 +453,7 @@ three-12345678 three''', '', 0),
'--health-timeout=10s', '--health-retries=3',
'--privileged=true', '--restart=always', '--user=bar',
'--log-opt=tag={{.ImageName}}/{{.Name}}/{{.ID}}',
'--cpu-shares=600',
'--security-opt=label:disable', '--cpuset-cpus=0,1,2,3',
'--memory=1G',
'--memory-swap=1G',

+ 5
- 0
releasenotes/notes/cgroups-cpu-shares-038ced471b862b4e.yaml View File

@@ -0,0 +1,5 @@
---
features:
- |
Add `--cpu-shares=xxx` option for the action run a container. Allows to
define upper `cpu.shares` limits in the cpu cgroup.

Loading…
Cancel
Save