Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
docker-py
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
docker-py
Commits
48e45afe
Kaydet (Commit)
48e45afe
authored
Şub 14, 2018
tarafından
Joffrey F
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add support for device_cgroup_rules parameter in host config
Signed-off-by:
Joffrey F
<
joffrey@docker.com
>
üst
9e75609a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
1 deletion
+31
-1
container.py
docker/api/container.py
+2
-0
containers.py
docker/models/containers.py
+3
-0
containers.py
docker/types/containers.py
+11
-1
api_container_test.py
tests/integration/api_container_test.py
+15
-0
No files found.
docker/api/container.py
Dosyayı görüntüle @
48e45afe
...
@@ -438,6 +438,8 @@ class ContainerApiMixin(object):
...
@@ -438,6 +438,8 @@ class ContainerApiMixin(object):
``0,1``).
``0,1``).
cpuset_mems (str): Memory nodes (MEMs) in which to allow execution
cpuset_mems (str): Memory nodes (MEMs) in which to allow execution
(``0-3``, ``0,1``). Only effective on NUMA systems.
(``0-3``, ``0,1``). Only effective on NUMA systems.
device_cgroup_rules (:py:class:`list`): A list of cgroup rules to
apply to the container.
device_read_bps: Limit read rate (bytes per second) from a device
device_read_bps: Limit read rate (bytes per second) from a device
in the form of: `[{"Path": "device_path", "Rate": rate}]`
in the form of: `[{"Path": "device_path", "Rate": rate}]`
device_read_iops: Limit read rate (IO per second) from a device.
device_read_iops: Limit read rate (IO per second) from a device.
...
...
docker/models/containers.py
Dosyayı görüntüle @
48e45afe
...
@@ -515,6 +515,8 @@ class ContainerCollection(Collection):
...
@@ -515,6 +515,8 @@ class ContainerCollection(Collection):
(``0-3``, ``0,1``). Only effective on NUMA systems.
(``0-3``, ``0,1``). Only effective on NUMA systems.
detach (bool): Run container in the background and return a
detach (bool): Run container in the background and return a
:py:class:`Container` object.
:py:class:`Container` object.
device_cgroup_rules (:py:class:`list`): A list of cgroup rules to
apply to the container.
device_read_bps: Limit read rate (bytes per second) from a device
device_read_bps: Limit read rate (bytes per second) from a device
in the form of: `[{"Path": "device_path", "Rate": rate}]`
in the form of: `[{"Path": "device_path", "Rate": rate}]`
device_read_iops: Limit read rate (IO per second) from a device.
device_read_iops: Limit read rate (IO per second) from a device.
...
@@ -912,6 +914,7 @@ RUN_HOST_CONFIG_KWARGS = [
...
@@ -912,6 +914,7 @@ RUN_HOST_CONFIG_KWARGS = [
'cpuset_mems'
,
'cpuset_mems'
,
'cpu_rt_period'
,
'cpu_rt_period'
,
'cpu_rt_runtime'
,
'cpu_rt_runtime'
,
'device_cgroup_rules'
,
'device_read_bps'
,
'device_read_bps'
,
'device_read_iops'
,
'device_read_iops'
,
'device_write_bps'
,
'device_write_bps'
,
...
...
docker/types/containers.py
Dosyayı görüntüle @
48e45afe
...
@@ -120,7 +120,8 @@ class HostConfig(dict):
...
@@ -120,7 +120,8 @@ class HostConfig(dict):
init
=
None
,
init_path
=
None
,
volume_driver
=
None
,
init
=
None
,
init_path
=
None
,
volume_driver
=
None
,
cpu_count
=
None
,
cpu_percent
=
None
,
nano_cpus
=
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
):
cpu_rt_period
=
None
,
cpu_rt_runtime
=
None
,
device_cgroup_rules
=
None
):
if
mem_limit
is
not
None
:
if
mem_limit
is
not
None
:
self
[
'Memory'
]
=
parse_bytes
(
mem_limit
)
self
[
'Memory'
]
=
parse_bytes
(
mem_limit
)
...
@@ -466,6 +467,15 @@ class HostConfig(dict):
...
@@ -466,6 +467,15 @@ class HostConfig(dict):
raise
host_config_version_error
(
'mounts'
,
'1.30'
)
raise
host_config_version_error
(
'mounts'
,
'1.30'
)
self
[
'Mounts'
]
=
mounts
self
[
'Mounts'
]
=
mounts
if
device_cgroup_rules
is
not
None
:
if
version_lt
(
version
,
'1.28'
):
raise
host_config_version_error
(
'device_cgroup_rules'
,
'1.28'
)
if
not
isinstance
(
device_cgroup_rules
,
list
):
raise
host_config_type_error
(
'device_cgroup_rules'
,
device_cgroup_rules
,
'list'
)
self
[
'DeviceCgroupRules'
]
=
device_cgroup_rules
def
host_config_type_error
(
param
,
param_value
,
expected
):
def
host_config_type_error
(
param
,
param_value
,
expected
):
error_msg
=
'Invalid type for {0} param: expected {1} but found {2}'
error_msg
=
'Invalid type for {0} param: expected {1} but found {2}'
...
...
tests/integration/api_container_test.py
Dosyayı görüntüle @
48e45afe
...
@@ -474,6 +474,21 @@ class CreateContainerTest(BaseAPIIntegrationTest):
...
@@ -474,6 +474,21 @@ class CreateContainerTest(BaseAPIIntegrationTest):
assert
config
[
'HostConfig'
][
'CpuRealtimeRuntime'
]
==
500
assert
config
[
'HostConfig'
][
'CpuRealtimeRuntime'
]
==
500
assert
config
[
'HostConfig'
][
'CpuRealtimePeriod'
]
==
1000
assert
config
[
'HostConfig'
][
'CpuRealtimePeriod'
]
==
1000
@requires_api_version
(
'1.28'
)
def
test_create_with_device_cgroup_rules
(
self
):
rule
=
'c 7:128 rwm'
ctnr
=
self
.
client
.
create_container
(
BUSYBOX
,
'cat /sys/fs/cgroup/devices/devices.list'
,
host_config
=
self
.
client
.
create_host_config
(
device_cgroup_rules
=
[
rule
]
)
)
self
.
tmp_containers
.
append
(
ctnr
)
config
=
self
.
client
.
inspect_container
(
ctnr
)
assert
config
[
'HostConfig'
][
'DeviceCgroupRules'
]
==
[
rule
]
self
.
client
.
start
(
ctnr
)
assert
rule
in
self
.
client
.
logs
(
ctnr
)
.
decode
(
'utf-8'
)
class
VolumeBindTest
(
BaseAPIIntegrationTest
):
class
VolumeBindTest
(
BaseAPIIntegrationTest
):
def
setUp
(
self
):
def
setUp
(
self
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment