diff --git a/SOURCES/implement-cpu_rt_-switches.patch b/SOURCES/implement-cpu_rt_-switches.patch new file mode 100644 index 0000000..462b578 --- /dev/null +++ b/SOURCES/implement-cpu_rt_-switches.patch @@ -0,0 +1,142 @@ +From e2b5a06cfd5375efc9741ea6bdad1ed764a65e54 Mon Sep 17 00:00:00 2001 +From: Tomas Tomecek +Date: Wed, 6 Sep 2017 17:57:56 +0200 +Subject: [PATCH] implement cpu_rt_* switches for create_host_config + +Signed-off-by: Tomas Tomecek +--- + docker/utils/utils.py | 23 ++++++++++++++++++++++- + docs/hostconfig.md | 2 ++ + tests/integration/container_test.py | 28 ++++++++++++++++++++++++++++ + tests/unit/container_test.py | 25 +++++++++++++++++++++++++ + 4 files changed, 77 insertions(+), 1 deletion(-) + +diff --git a/docker/utils/utils.py b/docker/utils/utils.py +index 8d55b57..2a183a0 100644 +--- a/docker/utils/utils.py ++++ b/docker/utils/utils.py +@@ -609,7 +609,8 @@ def create_host_config(binds=None, port_bindings=None, lxc_conf=None, + device_write_iops=None, oom_kill_disable=False, + shm_size=None, sysctls=None, version=None, tmpfs=None, + oom_score_adj=None, dns_opt=None, cpu_shares=None, +- cpuset_cpus=None, userns_mode=None, pids_limit=None): ++ cpuset_cpus=None, userns_mode=None, pids_limit=None, ++ cpu_rt_period=None, cpu_rt_runtime=None): + + host_config = {} + +@@ -897,6 +898,26 @@ def create_host_config(binds=None, port_bindings=None, lxc_conf=None, + raise host_config_version_error('pids_limit', '1.23') + host_config["PidsLimit"] = pids_limit + ++ 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' ++ ) ++ host_config['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' ++ ) ++ host_config['CPURealtimeRuntime'] = cpu_rt_runtime ++ + return host_config + + +diff --git a/docs/hostconfig.md b/docs/hostconfig.md +index 008d5cf..c39a02c 100644 +--- a/docs/hostconfig.md ++++ b/docs/hostconfig.md +@@ -130,6 +130,8 @@ for example: + * userns_mode (str): Sets the user namespace mode for the container when user + namespace remapping option is enabled. Supported values are: `host` + * pids_limit (int): Tune a container’s pids limit. Set -1 for unlimited. ++* cpu_rt_runtime (int): Limit the CPU real-time runtime in microseconds. ++* cpu_rt_period (int): Limit the CPU real-time period in microseconds. + + **Returns** (dict) HostConfig dictionary + +diff --git a/tests/integration/container_test.py b/tests/integration/container_test.py +index e390acb..7d179d5 100644 +--- a/tests/integration/container_test.py ++++ b/tests/integration/container_test.py +@@ -1144,3 +1144,31 @@ class ContainerCPUTest(helpers.BaseTestCase): + self.client.start(container) + inspect_data = self.client.inspect_container(container) + self.assertEqual(inspect_data['HostConfig']['CpusetCpus'], cpuset_cpus) ++ ++ ++class ContainerCPURT(helpers.BaseTestCase): ++ @requires_api_version('1.25') ++ def test_container_cpu_rt_runtime(self): ++ cpu_rt_runtime = 1000 ++ container = self.client.create_container( ++ BUSYBOX, 'ls', host_config=self.client.create_host_config( ++ cpu_rt_runtime=cpu_rt_runtime ++ ) ++ ) ++ self.tmp_containers.append(container) ++ self.client.start(container) ++ inspect_data = self.client.inspect_container(container) ++ self.assertEqual(inspect_data['HostConfig']['CPURealtimeRuntime'], 1000) ++ ++ @requires_api_version('1.285') ++ def test_container_rt_period(self): ++ cpu_rt_period = 2000 ++ container = self.client.create_container( ++ BUSYBOX, 'ls', host_config=self.client.create_host_config( ++ cpu_rt_period=cpu_rt_period ++ ) ++ ) ++ self.tmp_containers.append(container) ++ self.client.start(container) ++ inspect_data = self.client.inspect_container(container) ++ self.assertEqual(inspect_data['HostConfig']['CPURealtimePeriod'], 2000) +diff --git a/tests/unit/container_test.py b/tests/unit/container_test.py +index db3dd74..8c7b2c1 100644 +--- a/tests/unit/container_test.py ++++ b/tests/unit/container_test.py +@@ -335,6 +335,31 @@ class CreateContainerTest(DockerClientTest): + self.assertEqual(args[1]['headers'], + {'Content-Type': 'application/json'}) + ++ @requires_api_version('1.25') ++ def test_create_container_with_rt(self): ++ self.client.create_container( ++ 'busybox', 'ls', host_config=self.client.create_host_config( ++ cpu_rt_period=1000, cpu_rt_runtime=1000 ++ ) ++ ) ++ ++ args = fake_request.call_args ++ self.assertEqual(args[0][1], ++ url_prefix + 'containers/create') ++ self.assertEqual(json.loads(args[1]['data']), ++ json.loads(''' ++ {"Tty": false, "Image": "busybox", ++ "Cmd": ["ls"], "AttachStdin": false, ++ "AttachStderr": true, ++ "AttachStdout": true, "OpenStdin": false, ++ "StdinOnce": false, ++ "NetworkDisabled": false, ++ "HostConfig": { ++ "CPURealtimePeriod": 1000, ++ "CPURealtimeRuntime": 1000, ++ "NetworkMode": "default" ++ }}''')) ++ + @requires_api_version('1.18') + def test_create_container_with_host_config_cpuset(self): + self.client.create_container( +-- +2.14.1 + diff --git a/SPECS/python-docker-py.spec b/SPECS/python-docker-py.spec index 3a86ca9..6d0aa56 100644 --- a/SPECS/python-docker-py.spec +++ b/SPECS/python-docker-py.spec @@ -7,13 +7,16 @@ Name: python-%{project} Version: 1.10.6 -Release: 1%{?dist} +Release: 3%{?dist} Summary: An API client for docker written in Python License: ASL 2.0 URL: https://github.com/%{owner}/%{project}/ Source0: https://github.com/%{owner}/%{project}/archive/%{commit}/%{project}-%{commit}.tar.gz +Source1: https://files.pythonhosted.org/packages/source/d/%{docker_pycreds_pypi_name}/%{docker_pycreds_pypi_name}-%{docker_pycreds_version}.tar.gz Patch1: remote-inspection.patch Patch2: setup-Neuter-extras_require-that-doesn-t-work-on-Cen.patch +# https://bugzilla.redhat.com/show_bug.cgi?id=1486189 +Patch3: implement-cpu_rt_-switches.patch BuildArch: noarch BuildRequires: python2-devel @@ -37,7 +40,6 @@ Provides: docker-python == %{version}-%{release} Summary: Python bindings for the docker credentials store API License: ASL 2.0 URL: https://github.com/shin-/dockerpy-creds/ -Source1: https://files.pythonhosted.org/packages/source/d/%{docker_pycreds_pypi_name}/%{docker_pycreds_pypi_name}-%{docker_pycreds_version}.tar.gz BuildArch: noarch Requires: python-six @@ -49,6 +51,7 @@ Python bindings for the docker credentials store API %setup -q -n %{project}-%{commit} %patch1 -p 1 %patch2 -p 1 +%patch3 -p 1 gzip -dc %{SOURCE1} | tar -xvvf - @@ -79,6 +82,12 @@ popd %changelog +* Wed Sep 06 2017 Tomas Tomecek - 1.10.6-3 +- fix the backport of cpu_rt_* options + +* Mon Sep 04 2017 Tomas Tomecek - 1.10.6-2 +- backport cpu_rt_* options, rhbz#1486189 + * Tue Dec 20 2016 Tomas Tomecek - 1.10.6-1 - update to 1.10.6