Skip to content

Commit e098dbf

Browse files
committed
Re-enable pid_mode checks for API < 1.24
Signed-off-by: Joffrey F <[email protected]>
1 parent 08872a3 commit e098dbf

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

docker/utils/utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,8 @@ def create_host_config(binds=None, port_bindings=None, lxc_conf=None,
753753
host_config['ShmSize'] = shm_size
754754

755755
if pid_mode:
756+
if version_lt(version, '1.24') and pid_mode != 'host':
757+
raise host_config_value_error('pid_mode', pid_mode)
756758
host_config['PidMode'] = pid_mode
757759

758760
if ipc_mode:

tests/integration/api_container_test.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -361,10 +361,6 @@ def test_create_with_memory_constraints_with_int(self):
361361
host_config = inspect['HostConfig']
362362
self.assertIn('MemorySwappiness', host_config)
363363

364-
def test_create_host_config_exception_raising(self):
365-
self.assertRaises(TypeError,
366-
self.client.create_host_config, mem_swappiness='40')
367-
368364
def test_create_with_environment_variable_no_value(self):
369365
container = self.client.create_container(
370366
BUSYBOX,

tests/unit/utils_test.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,19 @@ def test_create_host_config_with_isolation(self):
207207
version='1.24', isolation={'isolation': 'hyperv'}
208208
)
209209

210+
def test_create_host_config_pid_mode(self):
211+
with pytest.raises(ValueError):
212+
create_host_config(version='1.23', pid_mode='baccab125')
213+
214+
config = create_host_config(version='1.23', pid_mode='host')
215+
assert config.get('PidMode') == 'host'
216+
config = create_host_config(version='1.24', pid_mode='baccab125')
217+
assert config.get('PidMode') == 'baccab125'
218+
219+
def test_create_host_config_invalid_mem_swappiness(self):
220+
with pytest.raises(TypeError):
221+
create_host_config(version='1.24', mem_swappiness='40')
222+
210223

211224
class UlimitTest(unittest.TestCase):
212225
def test_create_host_config_dict_ulimit(self):

0 commit comments

Comments
 (0)