Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
Allow to limit cgroup cpu shares
Browse files Browse the repository at this point in the history
Related-bug: #1755605

Change-Id: I1f24866ea2ec01e3ef22571145efa25ab219bb3a
Signed-off-by: Bogdan Dobrelya <bdobreli@redhat.com>
  • Loading branch information
bogdando committed Mar 26, 2018
1 parent 9b8c252 commit 4a4f43a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions paunch/builder/compose1.py
Expand Up @@ -182,6 +182,8 @@ def docker_run_args(self, cmd, container):
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'])

Expand Down
2 changes: 2 additions & 0 deletions paunch/tests/test_builder_compose1.py
Expand Up @@ -419,6 +419,7 @@ def test_docker_run_args(self):
},
'env_file': '/tmp/foo.env',
'log_tag': '{{.ImageName}}/{{.Name}}/{{.ID}}',
'cpu_shares': 600,
'security_opt': 'label:disable'
}
}
Expand All @@ -434,6 +435,7 @@ def test_docker_run_args(self):
'--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', 'centos:7'],
cmd
)
Expand Down
5 changes: 5 additions & 0 deletions releasenotes/notes/cgroups-cpu-shares-038ced471b862b4e.yaml
@@ -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.

0 comments on commit 4a4f43a

Please sign in to comment.