summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoffrey F <joffrey@docker.com>2016-11-28 12:01:25 -0800
committerJoffrey F <joffrey@docker.com>2016-11-28 12:01:25 -0800
commit44e57fb95d94145a789cc29884756b7fd4e03fe1 (patch)
treee61b1ecfbb91d663b9a9a2f3535aa95767570c6f
parent7ef48c3769cc42115b59157847275b2d072d7e5f (diff)
downloaddocker-py-stepanstipl-allow_custom_pid_mode.tar.gz
Re-enable pid_mode checks for API < 1.24stepanstipl-allow_custom_pid_mode
Signed-off-by: Joffrey F <joffrey@docker.com>
-rw-r--r--docker/utils/utils.py2
-rw-r--r--tests/integration/api_container_test.py4
-rw-r--r--tests/unit/utils_test.py13
3 files changed, 15 insertions, 4 deletions
diff --git a/docker/utils/utils.py b/docker/utils/utils.py
index f4ad6f8..d053fee 100644
--- a/docker/utils/utils.py
+++ b/docker/utils/utils.py
@@ -736,6 +736,8 @@ def create_host_config(binds=None, port_bindings=None, lxc_conf=None,
host_config['ShmSize'] = shm_size
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 60c6ec0..f09e75a 100644
--- a/tests/integration/api_container_test.py
+++ b/tests/integration/api_container_test.py
@@ -361,10 +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')
-
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 57aa226..c0eba60 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):