From 6a151aac046b18f4fe2ac46f79dc9c8ee83aa33a Mon Sep 17 00:00:00 2001 From: Yaroslav Molochko Date: Wed, 23 Nov 2016 12:12:57 -0800 Subject: [PATCH] introducing pids_limit, fix for #4178 Signed-off-by: Yaroslav Molochko --- compose/config/config.py | 1 + compose/config/config_schema_v2.1.json | 1 + compose/config/config_schema_v3.0.json | 1 + compose/service.py | 2 ++ tests/integration/service_test.py | 7 +++++++ 5 files changed, 12 insertions(+) diff --git a/compose/config/config.py b/compose/config/config.py index 003b2e2f4..a106a758a 100644 --- a/compose/config/config.py +++ b/compose/config/config.py @@ -87,6 +87,7 @@ DOCKER_CONFIG_KEYS = [ 'secrets', 'security_opt', 'shm_size', + 'pids_limit', 'stdin_open', 'stop_signal', 'sysctls', diff --git a/compose/config/config_schema_v2.1.json b/compose/config/config_schema_v2.1.json index d1ffff89a..0f4455a7d 100644 --- a/compose/config/config_schema_v2.1.json +++ b/compose/config/config_schema_v2.1.json @@ -216,6 +216,7 @@ "security_opt": {"type": "array", "items": {"type": "string"}, "uniqueItems": true}, "shm_size": {"type": ["number", "string"]}, "sysctls": {"$ref": "#/definitions/list_or_dict"}, + "pids_limit": {"type": ["number", "string"]}, "stdin_open": {"type": "boolean"}, "stop_grace_period": {"type": "string", "format": "duration"}, "stop_signal": {"type": "string"}, diff --git a/compose/config/config_schema_v3.0.json b/compose/config/config_schema_v3.0.json index fbcd8bb85..02a4e851d 100644 --- a/compose/config/config_schema_v3.0.json +++ b/compose/config/config_schema_v3.0.json @@ -168,6 +168,7 @@ "security_opt": {"type": "array", "items": {"type": "string"}, "uniqueItems": true}, "shm_size": {"type": ["number", "string"]}, "sysctls": {"$ref": "#/definitions/list_or_dict"}, + "pids_limit": {"type": ["number", "string"]}, "stdin_open": {"type": "boolean"}, "stop_grace_period": {"type": "string", "format": "duration"}, "stop_signal": {"type": "string"}, diff --git a/compose/service.py b/compose/service.py index b42094e68..c924f9ece 100644 --- a/compose/service.py +++ b/compose/service.py @@ -66,6 +66,7 @@ DOCKER_START_KEYS = [ 'oom_score_adj', 'mem_swappiness', 'pid', + 'pids_limit', 'privileged', 'restart', 'security_opt', @@ -772,6 +773,7 @@ class Service(object): cpu_quota=options.get('cpu_quota'), shm_size=options.get('shm_size'), sysctls=options.get('sysctls'), + pids_limit=options.get('pids_limit'), tmpfs=options.get('tmpfs'), oom_score_adj=options.get('oom_score_adj'), mem_swappiness=options.get('mem_swappiness'), diff --git a/tests/integration/service_test.py b/tests/integration/service_test.py index 734da5dfa..5e3815011 100644 --- a/tests/integration/service_test.py +++ b/tests/integration/service_test.py @@ -115,6 +115,13 @@ class ServiceTest(DockerClientTestCase): service.start_container(container) self.assertEqual(container.get('HostConfig.ShmSize'), 67108864) + def test_create_container_with_pids_limit(self): + self.require_api_version('1.23') + service = self.create_service('db', pids_limit=10) + container = service.create_container() + service.start_container(container) + self.assertEqual(container.get('HostConfig.PidsLimit'), 10) + def test_create_container_with_extra_hosts_list(self): extra_hosts = ['somehost:162.242.195.82', 'otherhost:50.31.209.229'] service = self.create_service('db', extra_hosts=extra_hosts)