diff options
author | Joffrey F <f.joffrey@gmail.com> | 2016-11-28 14:00:07 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-28 14:00:07 -0800 |
commit | 9643253c50aacc57ec66453137599ddeeee10d84 (patch) | |
tree | dcc2e882d03c3758920f3acc72b751d9502f8d1a | |
parent | 75e9d357f798224314a1af3d9cade6c05b866402 (diff) | |
parent | 44e57fb95d94145a789cc29884756b7fd4e03fe1 (diff) | |
download | docker-py-9643253c50aacc57ec66453137599ddeeee10d84.tar.gz |
Merge pull request #1297 from docker/stepanstipl-allow_custom_pid_mode
Allow custom pid mode
-rw-r--r-- | docker/utils/utils.py | 6 | ||||
-rw-r--r-- | tests/integration/api_container_test.py | 7 | ||||
-rw-r--r-- | tests/unit/utils_test.py | 13 |
3 files changed, 16 insertions, 10 deletions
diff --git a/docker/utils/utils.py b/docker/utils/utils.py index 45adf3b..823894c 100644 --- a/docker/utils/utils.py +++ b/docker/utils/utils.py @@ -735,9 +735,9 @@ def create_host_config(binds=None, port_bindings=None, lxc_conf=None, host_config['ShmSize'] = shm_size - if pid_mode not in (None, 'host'): - raise host_config_value_error('pid_mode', pid_mode) - elif pid_mode: + if pid_mode: + if version_lt(version, '1.24') and pid_mode != 'host': + raise host_config_value_error('pid_mode', pid_mode) host_config['PidMode'] = pid_mode if ipc_mode: diff --git a/tests/integration/api_container_test.py b/tests/integration/api_container_test.py index a5be6e7..f09e75a 100644 --- a/tests/integration/api_container_test.py +++ b/tests/integration/api_container_test.py @@ -361,13 +361,6 @@ class CreateContainerTest(BaseAPIIntegrationTest): host_config = inspect['HostConfig'] self.assertIn('MemorySwappiness', host_config) - def test_create_host_config_exception_raising(self): - self.assertRaises(TypeError, - self.client.create_host_config, mem_swappiness='40') - - self.assertRaises(ValueError, - self.client.create_host_config, pid_mode='40') - def test_create_with_environment_variable_no_value(self): container = self.client.create_container( BUSYBOX, diff --git a/tests/unit/utils_test.py b/tests/unit/utils_test.py index 9166ed9..19d52c9 100644 --- a/tests/unit/utils_test.py +++ b/tests/unit/utils_test.py @@ -205,6 +205,19 @@ class HostConfigTest(unittest.TestCase): version='1.24', isolation={'isolation': 'hyperv'} ) + def test_create_host_config_pid_mode(self): + with pytest.raises(ValueError): + create_host_config(version='1.23', pid_mode='baccab125') + + config = create_host_config(version='1.23', pid_mode='host') + assert config.get('PidMode') == 'host' + config = create_host_config(version='1.24', pid_mode='baccab125') + assert config.get('PidMode') == 'baccab125' + + def test_create_host_config_invalid_mem_swappiness(self): + with pytest.raises(TypeError): + create_host_config(version='1.24', mem_swappiness='40') + class UlimitTest(unittest.TestCase): def test_create_host_config_dict_ulimit(self): |