Skip to content

Commit 902c7a7

Browse files
committed
Docs and tests for pids_limit.
Signed-off-by: Joffrey F <[email protected]>
1 parent bf2235b commit 902c7a7

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

docs/hostconfig.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,12 @@ for example:
111111
CPU period.
112112
* cpu_shares (int): CPU shares (relative weight)
113113
* cpuset_cpus (str): CPUs in which to allow execution (0-3, 0,1)
114-
* blkio_weight: Block IO weight (relative weight), accepts a weight value between 10 and 1000.
114+
* blkio_weight: Block IO weight (relative weight), accepts a weight value
115+
between 10 and 1000.
115116
* blkio_weight_device: Block IO weight (relative device weight) in the form of:
116117
`[{"Path": "device_path", "Weight": weight}]`
117-
* device_read_bps: Limit read rate (bytes per second) from a device in the form of:
118-
`[{"Path": "device_path", "Rate": rate}]`
118+
* device_read_bps: Limit read rate (bytes per second) from a device in the
119+
form of: `[{"Path": "device_path", "Rate": rate}]`
119120
* device_write_bps: Limit write rate (bytes per second) from a device.
120121
* device_read_iops: Limit read rate (IO per second) from a device.
121122
* device_write_iops: Limit write rate (IO per second) from a device.
@@ -128,6 +129,7 @@ for example:
128129
* sysctls (dict): Kernel parameters to set in the container.
129130
* userns_mode (str): Sets the user namespace mode for the container when user
130131
namespace remapping option is enabled. Supported values are: `host`
132+
* pids_limit (int): Tune a container’s pids limit. Set -1 for unlimited.
131133

132134
**Returns** (dict) HostConfig dictionary
133135

tests/unit/utils_test.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,15 @@ def test_create_host_config_with_kernel_memory(self):
185185
InvalidVersion, lambda: create_host_config(
186186
version='1.20', kernel_memory=67108864))
187187

188+
def test_create_host_config_with_pids_limit(self):
189+
config = create_host_config(version='1.23', pids_limit=1024)
190+
self.assertEqual(config.get('PidsLimit'), 1024)
191+
192+
with pytest.raises(InvalidVersion):
193+
create_host_config(version='1.22', pids_limit=1024)
194+
with pytest.raises(TypeError):
195+
create_host_config(version='1.22', pids_limit='1024')
196+
188197

189198
class UlimitTest(base.BaseTestCase):
190199
def test_create_host_config_dict_ulimit(self):

0 commit comments

Comments
 (0)