Allow to set limit memory on containers
This will add the features `--memory`, `--memory-swap` and `--memory-swappiness` Change-Id: Icb44564906dbbe2d0407eaf1ab01eb450fcc73ce Closes-Bug: #1801949
This commit is contained in:
parent
791766596c
commit
797e7ae19c
|
@ -62,6 +62,9 @@ class ComposeV1Builder(base.BaseBuilder):
|
|||
if 'log_tag' in cconfig:
|
||||
cmd.append('--log-opt=tag=%s' % cconfig['log_tag'])
|
||||
self.string_arg(cconfig, cmd, 'cpu_shares', '--cpu-shares')
|
||||
self.string_arg(cconfig, cmd, 'mem_limit', '--memory')
|
||||
self.string_arg(cconfig, cmd, 'memswap_limit', '--memory-swap')
|
||||
self.string_arg(cconfig, cmd, 'mem_swappiness', '--memory-swappiness')
|
||||
self.string_arg(cconfig, cmd, 'security_opt', '--security-opt')
|
||||
self.string_arg(cconfig, cmd, 'stop_signal', '--stop-signal')
|
||||
|
||||
|
@ -88,9 +91,8 @@ class ComposeV1Builder(base.BaseBuilder):
|
|||
# domainname
|
||||
# hostname
|
||||
# mac_address
|
||||
# mem_limit
|
||||
# memswap_limit
|
||||
# mem_swappiness
|
||||
# memory_reservation
|
||||
# kernel_memory
|
||||
# read_only
|
||||
# shm_size
|
||||
# stdin_open
|
||||
|
|
|
@ -51,6 +51,9 @@ class PodmanBuilder(base.BaseBuilder):
|
|||
if 'log_tag' in cconfig:
|
||||
cmd.append('--log-opt=tag=%s' % cconfig['log_tag'])
|
||||
self.string_arg(cconfig, cmd, 'cpu_shares', '--cpu-shares')
|
||||
self.string_arg(cconfig, cmd, 'mem_limit', '--memory')
|
||||
self.string_arg(cconfig, cmd, 'memswap_limit', '--memory-swap')
|
||||
self.string_arg(cconfig, cmd, 'mem_swappiness', '--memory-swappiness')
|
||||
self.string_arg(cconfig, cmd, 'security_opt', '--security-opt')
|
||||
self.string_arg(cconfig, cmd, 'stop_signal', '--stop-signal')
|
||||
|
||||
|
|
|
@ -37,6 +37,9 @@ class TestComposeV1Builder(tbb.TestBaseBuilder):
|
|||
'env_file': '/tmp/foo.env',
|
||||
'log_tag': '{{.ImageName}}/{{.Name}}/{{.ID}}',
|
||||
'cpu_shares': 600,
|
||||
'mem_limit': '1G',
|
||||
'memswap_limit': '1G',
|
||||
'mem_swappiness': '60',
|
||||
'security_opt': 'label:disable',
|
||||
'cap_add': ['SYS_ADMIN', 'SETUID'],
|
||||
'cap_drop': ['NET_RAW']
|
||||
|
@ -55,6 +58,9 @@ class TestComposeV1Builder(tbb.TestBaseBuilder):
|
|||
'--privileged=true', '--restart=always', '--user=bar',
|
||||
'--log-opt=tag={{.ImageName}}/{{.Name}}/{{.ID}}',
|
||||
'--cpu-shares=600',
|
||||
'--memory=1G',
|
||||
'--memory-swap=1G',
|
||||
'--memory-swappiness=60',
|
||||
'--security-opt=label:disable',
|
||||
'--cap-add=SYS_ADMIN', '--cap-add=SETUID', '--cap-drop=NET_RAW',
|
||||
'centos:7'],
|
||||
|
|
|
@ -31,6 +31,9 @@ class TestPodmanBuilder(base.TestBaseBuilder):
|
|||
'env_file': '/tmp/foo.env',
|
||||
'log_tag': '{{.ImageName}}/{{.Name}}/{{.ID}}',
|
||||
'cpu_shares': 600,
|
||||
'mem_limit': '1G',
|
||||
'memswap_limit': '1G',
|
||||
'mem_swappiness': '60',
|
||||
'security_opt': 'label:disable',
|
||||
'cap_add': ['SYS_ADMIN', 'SETUID'],
|
||||
'cap_drop': ['NET_RAW']
|
||||
|
@ -47,6 +50,9 @@ class TestPodmanBuilder(base.TestBaseBuilder):
|
|||
'--uts=host', '--privileged=true', '--user=bar',
|
||||
'--log-opt=tag={{.ImageName}}/{{.Name}}/{{.ID}}',
|
||||
'--cpu-shares=600',
|
||||
'--memory=1G',
|
||||
'--memory-swap=1G',
|
||||
'--memory-swappiness=60',
|
||||
'--security-opt=label:disable',
|
||||
'--cap-add=SYS_ADMIN', '--cap-add=SETUID', '--cap-drop=NET_RAW',
|
||||
'centos:7'],
|
||||
|
|
|
@ -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