summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoffrey F <joffrey@docker.com>2017-12-13 18:50:07 -0800
committerJoffrey F <joffrey@docker.com>2017-12-13 18:50:07 -0800
commitd7bc8ac2b8507b93097f164ab994a138f9d6bab1 (patch)
treeb097bd1a34979ddcb02cc2ae5114f281debdb561
parent6c74292d3d24326876c25092f0a2aa9e6e024808 (diff)
parentd74f1bc3805176af229ae3d2e9e5dbe1f0b40a15 (diff)
downloaddocker-py-d7bc8ac2b8507b93097f164ab994a138f9d6bab1.tar.gz
Merge branch 'master' of https://github.com/tz70s/docker-py into tz70s-master
Signed-off-by: Joffrey F <joffrey@docker.com>
-rw-r--r--docker/models/containers.py2
-rw-r--r--docker/types/containers.py23
-rw-r--r--tests/unit/dockertypes_test.py22
3 files changed, 46 insertions, 1 deletions
diff --git a/docker/models/containers.py b/docker/models/containers.py
index 97a08b9..4e3d218 100644
--- a/docker/models/containers.py
+++ b/docker/models/containers.py
@@ -873,6 +873,8 @@ RUN_HOST_CONFIG_KWARGS = [
'cpu_shares',
'cpuset_cpus',
'cpuset_mems',
+ 'cpu_rt_period',
+ 'cpu_rt_runtime',
'device_read_bps',
'device_read_iops',
'device_write_bps',
diff --git a/docker/types/containers.py b/docker/types/containers.py
index 13bea71..15dd86c 100644
--- a/docker/types/containers.py
+++ b/docker/types/containers.py
@@ -120,7 +120,8 @@ class HostConfig(dict):
isolation=None, auto_remove=False, storage_opt=None,
init=None, init_path=None, volume_driver=None,
cpu_count=None, cpu_percent=None, nano_cpus=None,
- cpuset_mems=None, runtime=None, mounts=None):
+ cpuset_mems=None, runtime=None, mounts=None,
+ cpu_rt_period=None, cpu_rt_runtime=None):
if mem_limit is not None:
self['Memory'] = parse_bytes(mem_limit)
@@ -336,6 +337,26 @@ class HostConfig(dict):
)
self['CpusetMems'] = cpuset_mems
+ if cpu_rt_period:
+ if version_lt(version, '1.25'):
+ raise host_config_version_error('cpu_rt_period', '1.25')
+
+ if not isinstance(cpu_rt_period, int):
+ raise host_config_type_error(
+ 'cpu_rt_period', cpu_rt_period, 'int'
+ )
+ self['CPURealtimePeriod'] = cpu_rt_period
+
+ if cpu_rt_runtime:
+ if version_lt(version, '1.25'):
+ raise host_config_version_error('cpu_rt_runtime', '1.25')
+
+ if not isinstance(cpu_rt_runtime, int):
+ raise host_config_type_error(
+ 'cpu_rt_runtime', cpu_rt_runtime, 'int'
+ )
+ self['CPURealtimeRuntime'] = cpu_rt_runtime
+
if blkio_weight:
if not isinstance(blkio_weight, int):
raise host_config_type_error(
diff --git a/tests/unit/dockertypes_test.py b/tests/unit/dockertypes_test.py
index 8dbb35e..40adbb7 100644
--- a/tests/unit/dockertypes_test.py
+++ b/tests/unit/dockertypes_test.py
@@ -206,6 +206,28 @@ class HostConfigTest(unittest.TestCase):
InvalidVersion, lambda: create_host_config(
version='1.24', nano_cpus=1))
+ def test_create_host_config_with_cpu_rt_period_types(self):
+ with pytest.raises(TypeError):
+ create_host_config(version='1.25', cpu_rt_period='1000')
+
+ def test_create_host_config_with_cpu_rt_period(self):
+ config = create_host_config(version='1.25', cpu_rt_period=1000)
+ self.assertEqual(config.get('CPURealtimePeriod'), 1000)
+ self.assertRaises(
+ InvalidVersion, lambda: create_host_config(
+ version='1.24', cpu_rt_period=1000))
+
+ def test_ctrate_host_config_with_cpu_rt_runtime_types(self):
+ with pytest.raises(TypeError):
+ create_host_config(version='1.25', cpu_rt_runtime='1000')
+
+ def test_create_host_config_with_cpu_rt_runtime(self):
+ config = create_host_config(version='1.25', cpu_rt_runtime=1000)
+ self.assertEqual(config.get('CPURealtimeRuntime'), 1000)
+ self.assertRaises(
+ InvalidVersion, lambda: create_host_config(
+ version='1.24', cpu_rt_runtime=1000))
+
class ContainerConfigTest(unittest.TestCase):
def test_create_container_config_volume_driver_warning(self):