mirror of https://github.com/docker/compose.git
Merge pull request #3542 from jfroche/add_swappiness
Add support for swappiness constraint
This commit is contained in:
commit
acfe100686
|
@ -69,6 +69,7 @@ DOCKER_CONFIG_KEYS = [
|
||||||
'mac_address',
|
'mac_address',
|
||||||
'mem_limit',
|
'mem_limit',
|
||||||
'memswap_limit',
|
'memswap_limit',
|
||||||
|
'mem_swappiness',
|
||||||
'net',
|
'net',
|
||||||
'oom_score_adj'
|
'oom_score_adj'
|
||||||
'pid',
|
'pid',
|
||||||
|
|
|
@ -85,6 +85,7 @@
|
||||||
"mac_address": {"type": "string"},
|
"mac_address": {"type": "string"},
|
||||||
"mem_limit": {"type": ["number", "string"]},
|
"mem_limit": {"type": ["number", "string"]},
|
||||||
"memswap_limit": {"type": ["number", "string"]},
|
"memswap_limit": {"type": ["number", "string"]},
|
||||||
|
"mem_swappiness": {"type": "integer"},
|
||||||
"net": {"type": "string"},
|
"net": {"type": "string"},
|
||||||
"pid": {"type": ["string", "null"]},
|
"pid": {"type": ["string", "null"]},
|
||||||
|
|
||||||
|
|
|
@ -139,6 +139,7 @@
|
||||||
"mac_address": {"type": "string"},
|
"mac_address": {"type": "string"},
|
||||||
"mem_limit": {"type": ["number", "string"]},
|
"mem_limit": {"type": ["number", "string"]},
|
||||||
"memswap_limit": {"type": ["number", "string"]},
|
"memswap_limit": {"type": ["number", "string"]},
|
||||||
|
"mem_swappiness": {"type": "integer"},
|
||||||
"network_mode": {"type": "string"},
|
"network_mode": {"type": "string"},
|
||||||
|
|
||||||
"networks": {
|
"networks": {
|
||||||
|
|
|
@ -55,6 +55,7 @@ DOCKER_START_KEYS = [
|
||||||
'mem_limit',
|
'mem_limit',
|
||||||
'memswap_limit',
|
'memswap_limit',
|
||||||
'oom_score_adj',
|
'oom_score_adj',
|
||||||
|
'mem_swappiness',
|
||||||
'pid',
|
'pid',
|
||||||
'privileged',
|
'privileged',
|
||||||
'restart',
|
'restart',
|
||||||
|
@ -704,7 +705,8 @@ class Service(object):
|
||||||
cpu_quota=options.get('cpu_quota'),
|
cpu_quota=options.get('cpu_quota'),
|
||||||
shm_size=options.get('shm_size'),
|
shm_size=options.get('shm_size'),
|
||||||
tmpfs=options.get('tmpfs'),
|
tmpfs=options.get('tmpfs'),
|
||||||
oom_score_adj=options.get('oom_score_adj')
|
oom_score_adj=options.get('oom_score_adj'),
|
||||||
|
mem_swappiness=options.get('mem_swappiness')
|
||||||
)
|
)
|
||||||
|
|
||||||
def build(self, no_cache=False, pull=False, force_rm=False):
|
def build(self, no_cache=False, pull=False, force_rm=False):
|
||||||
|
|
|
@ -744,7 +744,7 @@ then read-write will be used.
|
||||||
> - container_name
|
> - container_name
|
||||||
> - container_name:rw
|
> - container_name:rw
|
||||||
|
|
||||||
### cpu\_shares, cpu\_quota, cpuset, domainname, hostname, ipc, mac\_address, mem\_limit, memswap\_limit, oom_score_adj, privileged, read\_only, restart, shm\_size, stdin\_open, tty, user, working\_dir
|
### cpu\_shares, cpu\_quota, cpuset, domainname, hostname, ipc, mac\_address, mem\_limit, memswap\_limit, mem\_swappiness, oom\_score\_adj, privileged, read\_only, restart, shm\_size, stdin\_open, tty, user, working\_dir
|
||||||
|
|
||||||
Each of these is a single value, analogous to its
|
Each of these is a single value, analogous to its
|
||||||
[docker run](https://docs.docker.com/engine/reference/run/) counterpart.
|
[docker run](https://docs.docker.com/engine/reference/run/) counterpart.
|
||||||
|
@ -763,6 +763,7 @@ Each of these is a single value, analogous to its
|
||||||
|
|
||||||
mem_limit: 1000000000
|
mem_limit: 1000000000
|
||||||
memswap_limit: 2000000000
|
memswap_limit: 2000000000
|
||||||
|
mem_swappiness: 10
|
||||||
privileged: true
|
privileged: true
|
||||||
|
|
||||||
restart: always
|
restart: always
|
||||||
|
|
|
@ -852,6 +852,11 @@ class ServiceTest(DockerClientTestCase):
|
||||||
container = create_and_start_container(service)
|
container = create_and_start_container(service)
|
||||||
self.assertEqual(container.get('HostConfig.Dns'), ['8.8.8.8', '9.9.9.9'])
|
self.assertEqual(container.get('HostConfig.Dns'), ['8.8.8.8', '9.9.9.9'])
|
||||||
|
|
||||||
|
def test_mem_swappiness(self):
|
||||||
|
service = self.create_service('web', mem_swappiness=11)
|
||||||
|
container = create_and_start_container(service)
|
||||||
|
self.assertEqual(container.get('HostConfig.MemorySwappiness'), 11)
|
||||||
|
|
||||||
def test_restart_always_value(self):
|
def test_restart_always_value(self):
|
||||||
service = self.create_service('web', restart={'Name': 'always'})
|
service = self.create_service('web', restart={'Name': 'always'})
|
||||||
container = create_and_start_container(service)
|
container = create_and_start_container(service)
|
||||||
|
|
|
@ -1271,6 +1271,24 @@ class ConfigTest(unittest.TestCase):
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def test_swappiness_option(self):
|
||||||
|
actual = config.load(build_config_details({
|
||||||
|
'version': '2',
|
||||||
|
'services': {
|
||||||
|
'web': {
|
||||||
|
'image': 'alpine',
|
||||||
|
'mem_swappiness': 10,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
assert actual.services == [
|
||||||
|
{
|
||||||
|
'name': 'web',
|
||||||
|
'image': 'alpine',
|
||||||
|
'mem_swappiness': 10,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
def test_merge_service_dicts_from_files_with_extends_in_base(self):
|
def test_merge_service_dicts_from_files_with_extends_in_base(self):
|
||||||
base = {
|
base = {
|
||||||
'volumes': ['.:/app'],
|
'volumes': ['.:/app'],
|
||||||
|
|
Loading…
Reference in New Issue