Skip to content

Commit

Permalink
Add support for oom_kill_disable in service config
Browse files Browse the repository at this point in the history
Signed-off-by: Joffrey F <joffrey@docker.com>
  • Loading branch information
shin- committed Oct 26, 2017
1 parent b30cb77 commit 80503da
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions compose/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
'mem_swappiness',
'net',
'oom_score_adj',
'oom_kill_disable',
'pid',
'ports',
'privileged',
Expand Down
1 change: 1 addition & 0 deletions compose/config/config_schema_v2.1.json
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@
}
]
},
"oom_kill_disable": {"type": "boolean"},
"oom_score_adj": {"type": "integer", "minimum": -1000, "maximum": 1000},
"group_add": {
"type": "array",
Expand Down
1 change: 1 addition & 0 deletions compose/config/config_schema_v2.2.json
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@
}
]
},
"oom_kill_disable": {"type": "boolean"},
"oom_score_adj": {"type": "integer", "minimum": -1000, "maximum": 1000},
"group_add": {
"type": "array",
Expand Down
1 change: 1 addition & 0 deletions compose/config/config_schema_v2.3.json
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@
}
]
},
"oom_kill_disable": {"type": "boolean"},
"oom_score_adj": {"type": "integer", "minimum": -1000, "maximum": 1000},
"group_add": {
"type": "array",
Expand Down
1 change: 1 addition & 0 deletions compose/config/interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ class ConversionMap(object):
service_path('deploy', 'update_config', 'max_failure_ratio'): float,
service_path('deploy', 'restart_policy', 'max_attempts'): to_int,
service_path('mem_swappiness'): to_int,
service_path('oom_kill_disable'): to_boolean,
service_path('oom_score_adj'): to_int,
service_path('ports', 'target'): to_int,
service_path('ports', 'published'): to_int,
Expand Down
2 changes: 2 additions & 0 deletions compose/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
'mem_reservation',
'memswap_limit',
'mem_swappiness',
'oom_kill_disable',
'oom_score_adj',
'pid',
'pids_limit',
Expand Down Expand Up @@ -859,6 +860,7 @@ def _get_container_host_config(self, override_options, one_off=False):
sysctls=options.get('sysctls'),
pids_limit=options.get('pids_limit'),
tmpfs=options.get('tmpfs'),
oom_kill_disable=options.get('oom_kill_disable'),
oom_score_adj=options.get('oom_score_adj'),
mem_swappiness=options.get('mem_swappiness'),
group_add=options.get('group_add'),
Expand Down
9 changes: 7 additions & 2 deletions tests/integration/service_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,15 +239,20 @@ def test_create_container_with_security_opt(self):
service.start_container(container)
self.assertEqual(set(container.get('HostConfig.SecurityOpt')), set(security_opt))

# @pytest.mark.xfail(True, reason='Not supported on most drivers')
@pytest.mark.skipif(True, reason='https://github.com/moby/moby/issues/34270')
@pytest.mark.xfail(True, reason='Not supported on most drivers')
def test_create_container_with_storage_opt(self):
storage_opt = {'size': '1G'}
service = self.create_service('db', storage_opt=storage_opt)
container = service.create_container()
service.start_container(container)
self.assertEqual(container.get('HostConfig.StorageOpt'), storage_opt)

def test_create_container_with_oom_kill_disable(self):
self.require_api_version('1.20')
service = self.create_service('db', oom_kill_disable=True)
container = service.create_container()
assert container.get('HostConfig.OomKillDisable') is True

def test_create_container_with_mac_address(self):
service = self.create_service('db', mac_address='02:42:ac:11:65:43')
container = service.create_container()
Expand Down

0 comments on commit 80503da

Please sign in to comment.