Allow to set limit memory on containers
This will add the features `--memory`, `--memory-swap` and
`--memory-swappiness`
Conflicts:
paunch/builder/compose1.py
paunch/builder/podman.py
paunch/tests/test_builder_compose1.py
paunch/tests/test_builder_podman.py
Change-Id: Icb44564906dbbe2d0407eaf1ab01eb450fcc73ce
Closes-Bug: #1801949
(cherry picked from commit 797e7ae19c
)
This commit is contained in:
parent
6c97d9eae9
commit
ccc7b278c1
|
@ -199,6 +199,12 @@ class ComposeV1Builder(object):
|
||||||
cmd.append('--cpuset-cpus=%s' % cconfig['cpuset_cpus'])
|
cmd.append('--cpuset-cpus=%s' % cconfig['cpuset_cpus'])
|
||||||
else:
|
else:
|
||||||
cmd.append('--cpuset-cpus=%s' % common.get_cpus_allowed_list())
|
cmd.append('--cpuset-cpus=%s' % common.get_cpus_allowed_list())
|
||||||
|
if 'mem_limit' in cconfig:
|
||||||
|
cmd.append('--memory=%s' % cconfig['mem_limit'])
|
||||||
|
if 'memswap_limit' in cconfig:
|
||||||
|
cmd.append('--memory-swap=%s' % cconfig['memswap_limit'])
|
||||||
|
if 'mem_swappiness' in cconfig:
|
||||||
|
cmd.append('--memory-swappiness=%s' % cconfig['mem_swappiness'])
|
||||||
|
|
||||||
cmd.append(cconfig.get('image', ''))
|
cmd.append(cconfig.get('image', ''))
|
||||||
cmd.extend(self.command_argument(cconfig.get('command')))
|
cmd.extend(self.command_argument(cconfig.get('command')))
|
||||||
|
|
|
@ -434,7 +434,10 @@ three-12345678 three''', '', 0),
|
||||||
},
|
},
|
||||||
'env_file': '/tmp/foo.env',
|
'env_file': '/tmp/foo.env',
|
||||||
'log_tag': '{{.ImageName}}/{{.Name}}/{{.ID}}',
|
'log_tag': '{{.ImageName}}/{{.Name}}/{{.ID}}',
|
||||||
'security_opt': 'label:disable'
|
'security_opt': 'label:disable',
|
||||||
|
'mem_limit': '1G',
|
||||||
|
'memswap_limit': '1G',
|
||||||
|
'mem_swappiness': '60'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
builder = compose1.ComposeV1Builder('foo', config, None)
|
builder = compose1.ComposeV1Builder('foo', config, None)
|
||||||
|
@ -450,6 +453,9 @@ three-12345678 three''', '', 0),
|
||||||
'--privileged=true', '--restart=always', '--user=bar',
|
'--privileged=true', '--restart=always', '--user=bar',
|
||||||
'--log-opt=tag={{.ImageName}}/{{.Name}}/{{.ID}}',
|
'--log-opt=tag={{.ImageName}}/{{.Name}}/{{.ID}}',
|
||||||
'--security-opt=label:disable', '--cpuset-cpus=0,1,2,3',
|
'--security-opt=label:disable', '--cpuset-cpus=0,1,2,3',
|
||||||
|
'--memory=1G',
|
||||||
|
'--memory-swap=1G',
|
||||||
|
'--memory-swappiness=60',
|
||||||
'centos:7'],
|
'centos:7'],
|
||||||
cmd
|
cmd
|
||||||
)
|
)
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Add `--memory=x` option for the action run a container. This allows
|
||||||
|
setting constraints on max memory usage, which is `memory.limit_in_bytes`
|
||||||
|
in memory cgroup.
|
||||||
|
Also added `--memory-swap` and `--memory-swappiness` options to control
|
||||||
|
swap settings.
|
Loading…
Reference in New Issue