Allow to set limit memory on containers
This will add the features `--memory`, `--memory-swap` and
`--memory-swappiness`
Conflicts:
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
60bb706f84
commit
d878e224fc
|
@ -208,6 +208,9 @@ class ComposeV1Builder(object):
|
||||||
if 'log_tag' in cconfig:
|
if 'log_tag' in cconfig:
|
||||||
cmd.append('--log-opt=tag=%s' % cconfig['log_tag'])
|
cmd.append('--log-opt=tag=%s' % cconfig['log_tag'])
|
||||||
self.string_arg(cconfig, cmd, 'cpu_shares', '--cpu-shares')
|
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, 'security_opt', '--security-opt')
|
||||||
self.string_arg(cconfig, cmd, 'stop_signal', '--stop-signal')
|
self.string_arg(cconfig, cmd, 'stop_signal', '--stop-signal')
|
||||||
|
|
||||||
|
@ -262,9 +265,8 @@ class ComposeV1Builder(object):
|
||||||
# domainname
|
# domainname
|
||||||
# hostname
|
# hostname
|
||||||
# mac_address
|
# mac_address
|
||||||
# mem_limit
|
# memory_reservation
|
||||||
# memswap_limit
|
# kernel_memory
|
||||||
# mem_swappiness
|
|
||||||
# read_only
|
# read_only
|
||||||
# shm_size
|
# shm_size
|
||||||
# stdin_open
|
# stdin_open
|
||||||
|
|
|
@ -432,7 +432,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}}',
|
||||||
'cpu_shares': 600,
|
'cpu_shares': 600,
|
||||||
'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)
|
||||||
|
@ -449,6 +452,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}}',
|
||||||
'--cpu-shares=600',
|
'--cpu-shares=600',
|
||||||
|
'--memory=1G',
|
||||||
|
'--memory-swap=1G',
|
||||||
|
'--memory-swappiness=60',
|
||||||
'--security-opt=label:disable', 'centos:7'],
|
'--security-opt=label:disable', '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