Add support for oom_kill_disable in service config

Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
Joffrey F 2017-10-25 15:07:00 -07:00 committed by Joffrey F
parent b30cb77a7b
commit 80503da476
7 changed files with 14 additions and 2 deletions

View File

@ -91,6 +91,7 @@ DOCKER_CONFIG_KEYS = [
'mem_swappiness', 'mem_swappiness',
'net', 'net',
'oom_score_adj', 'oom_score_adj',
'oom_kill_disable',
'pid', 'pid',
'ports', 'ports',
'privileged', 'privileged',

View File

@ -229,6 +229,7 @@
} }
] ]
}, },
"oom_kill_disable": {"type": "boolean"},
"oom_score_adj": {"type": "integer", "minimum": -1000, "maximum": 1000}, "oom_score_adj": {"type": "integer", "minimum": -1000, "maximum": 1000},
"group_add": { "group_add": {
"type": "array", "type": "array",

View File

@ -235,6 +235,7 @@
} }
] ]
}, },
"oom_kill_disable": {"type": "boolean"},
"oom_score_adj": {"type": "integer", "minimum": -1000, "maximum": 1000}, "oom_score_adj": {"type": "integer", "minimum": -1000, "maximum": 1000},
"group_add": { "group_add": {
"type": "array", "type": "array",

View File

@ -237,6 +237,7 @@
} }
] ]
}, },
"oom_kill_disable": {"type": "boolean"},
"oom_score_adj": {"type": "integer", "minimum": -1000, "maximum": 1000}, "oom_score_adj": {"type": "integer", "minimum": -1000, "maximum": 1000},
"group_add": { "group_add": {
"type": "array", "type": "array",

View File

@ -156,6 +156,7 @@ class ConversionMap(object):
service_path('deploy', 'update_config', 'max_failure_ratio'): float, service_path('deploy', 'update_config', 'max_failure_ratio'): float,
service_path('deploy', 'restart_policy', 'max_attempts'): to_int, service_path('deploy', 'restart_policy', 'max_attempts'): to_int,
service_path('mem_swappiness'): to_int, service_path('mem_swappiness'): to_int,
service_path('oom_kill_disable'): to_boolean,
service_path('oom_score_adj'): to_int, service_path('oom_score_adj'): to_int,
service_path('ports', 'target'): to_int, service_path('ports', 'target'): to_int,
service_path('ports', 'published'): to_int, service_path('ports', 'published'): to_int,

View File

@ -77,6 +77,7 @@ HOST_CONFIG_KEYS = [
'mem_reservation', 'mem_reservation',
'memswap_limit', 'memswap_limit',
'mem_swappiness', 'mem_swappiness',
'oom_kill_disable',
'oom_score_adj', 'oom_score_adj',
'pid', 'pid',
'pids_limit', 'pids_limit',
@ -859,6 +860,7 @@ class Service(object):
sysctls=options.get('sysctls'), sysctls=options.get('sysctls'),
pids_limit=options.get('pids_limit'), pids_limit=options.get('pids_limit'),
tmpfs=options.get('tmpfs'), tmpfs=options.get('tmpfs'),
oom_kill_disable=options.get('oom_kill_disable'),
oom_score_adj=options.get('oom_score_adj'), oom_score_adj=options.get('oom_score_adj'),
mem_swappiness=options.get('mem_swappiness'), mem_swappiness=options.get('mem_swappiness'),
group_add=options.get('group_add'), group_add=options.get('group_add'),

View File

@ -239,8 +239,7 @@ class ServiceTest(DockerClientTestCase):
service.start_container(container) service.start_container(container)
self.assertEqual(set(container.get('HostConfig.SecurityOpt')), set(security_opt)) self.assertEqual(set(container.get('HostConfig.SecurityOpt')), set(security_opt))
# @pytest.mark.xfail(True, reason='Not supported on most drivers') @pytest.mark.xfail(True, reason='Not supported on most drivers')
@pytest.mark.skipif(True, reason='https://github.com/moby/moby/issues/34270')
def test_create_container_with_storage_opt(self): def test_create_container_with_storage_opt(self):
storage_opt = {'size': '1G'} storage_opt = {'size': '1G'}
service = self.create_service('db', storage_opt=storage_opt) service = self.create_service('db', storage_opt=storage_opt)
@ -248,6 +247,12 @@ class ServiceTest(DockerClientTestCase):
service.start_container(container) service.start_container(container)
self.assertEqual(container.get('HostConfig.StorageOpt'), storage_opt) 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): def test_create_container_with_mac_address(self):
service = self.create_service('db', mac_address='02:42:ac:11:65:43') service = self.create_service('db', mac_address='02:42:ac:11:65:43')
container = service.create_container() container = service.create_container()