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
538a1db9
Kaydet (Commit)
538a1db9
authored
Haz 15, 2016
tarafından
Joffrey F
Kaydeden (comit)
GitHub
Haz 15, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge pull request #1066 from yunzhu-li/blkio-control
Add support for Block IO constraints in HostConfig
üst
787f3f5a
896d36ea
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
85 additions
and
2 deletions
+85
-2
utils.py
docker/utils/utils.py
+58
-2
hostconfig.md
docs/hostconfig.md
+8
-0
utils_test.py
tests/unit/utils_test.py
+19
-0
No files found.
docker/utils/utils.py
Dosyayı görüntüle @
538a1db9
...
...
@@ -615,8 +615,12 @@ def create_host_config(binds=None, port_bindings=None, lxc_conf=None,
security_opt
=
None
,
ulimits
=
None
,
log_config
=
None
,
mem_limit
=
None
,
memswap_limit
=
None
,
mem_swappiness
=
None
,
cgroup_parent
=
None
,
group_add
=
None
,
cpu_quota
=
None
,
cpu_period
=
None
,
oom_kill_disable
=
False
,
shm_size
=
None
,
version
=
None
,
tmpfs
=
None
,
oom_score_adj
=
None
):
cpu_period
=
None
,
blkio_weight
=
None
,
blkio_weight_device
=
None
,
device_read_bps
=
None
,
device_write_bps
=
None
,
device_read_iops
=
None
,
device_write_iops
=
None
,
oom_kill_disable
=
False
,
shm_size
=
None
,
version
=
None
,
tmpfs
=
None
,
oom_score_adj
=
None
):
host_config
=
{}
...
...
@@ -792,6 +796,58 @@ def create_host_config(binds=None, port_bindings=None, lxc_conf=None,
host_config
[
'CpuPeriod'
]
=
cpu_period
if
blkio_weight
:
if
not
isinstance
(
blkio_weight
,
int
):
raise
host_config_type_error
(
'blkio_weight'
,
blkio_weight
,
'int'
)
if
version_lt
(
version
,
'1.22'
):
raise
host_config_version_error
(
'blkio_weight'
,
'1.22'
)
host_config
[
"BlkioWeight"
]
=
blkio_weight
if
blkio_weight_device
:
if
not
isinstance
(
blkio_weight_device
,
list
):
raise
host_config_type_error
(
'blkio_weight_device'
,
blkio_weight_device
,
'list'
)
if
version_lt
(
version
,
'1.22'
):
raise
host_config_version_error
(
'blkio_weight_device'
,
'1.22'
)
host_config
[
"BlkioWeightDevice"
]
=
blkio_weight_device
if
device_read_bps
:
if
not
isinstance
(
device_read_bps
,
list
):
raise
host_config_type_error
(
'device_read_bps'
,
device_read_bps
,
'list'
)
if
version_lt
(
version
,
'1.22'
):
raise
host_config_version_error
(
'device_read_bps'
,
'1.22'
)
host_config
[
"BlkioDeviceReadBps"
]
=
device_read_bps
if
device_write_bps
:
if
not
isinstance
(
device_write_bps
,
list
):
raise
host_config_type_error
(
'device_write_bps'
,
device_write_bps
,
'list'
)
if
version_lt
(
version
,
'1.22'
):
raise
host_config_version_error
(
'device_write_bps'
,
'1.22'
)
host_config
[
"BlkioDeviceWriteBps"
]
=
device_write_bps
if
device_read_iops
:
if
not
isinstance
(
device_read_iops
,
list
):
raise
host_config_type_error
(
'device_read_iops'
,
device_read_iops
,
'list'
)
if
version_lt
(
version
,
'1.22'
):
raise
host_config_version_error
(
'device_read_iops'
,
'1.22'
)
host_config
[
"BlkioDeviceReadIOps"
]
=
device_read_iops
if
device_write_iops
:
if
not
isinstance
(
device_write_iops
,
list
):
raise
host_config_type_error
(
'device_write_iops'
,
device_write_iops
,
'list'
)
if
version_lt
(
version
,
'1.22'
):
raise
host_config_version_error
(
'device_write_iops'
,
'1.22'
)
host_config
[
"BlkioDeviceWriteIOps"
]
=
device_write_iops
if
tmpfs
:
if
version_lt
(
version
,
'1.22'
):
raise
host_config_version_error
(
'tmpfs'
,
'1.22'
)
...
...
docs/hostconfig.md
Dosyayı görüntüle @
538a1db9
...
...
@@ -109,6 +109,14 @@ for example:
*
cpu_group (int): The length of a CPU period in microseconds.
*
cpu_period (int): Microseconds of CPU time that the container can get in a
CPU period.
*
blkio_weight: Block IO weight (relative weight), accepts a weight value between 10 and 1000.
*
blkio_weight_device: Block IO weight (relative device weight) in the form of:
`[{"Path": "device_path", "Weight": weight}]`
*
device_read_bps: Limit read rate (bytes per second) from a device in the form of:
`[{"Path": "device_path", "Rate": rate}]`
*
device_write_bps: Limit write rate (bytes per second) from a device.
*
device_read_iops: Limit read rate (IO per second) from a device.
*
device_write_iops: Limit write rate (IO per second) from a device.
*
group_add (list): List of additional group names and/or IDs that the
container process will run as.
*
devices (list): Host device bindings. See
[
host devices
](
host-devices.md
)
...
...
tests/unit/utils_test.py
Dosyayı görüntüle @
538a1db9
...
...
@@ -64,6 +64,25 @@ class HostConfigTest(base.BaseTestCase):
config
=
create_host_config
(
version
=
'1.20'
,
cpu_period
=
1999
)
self
.
assertEqual
(
config
.
get
(
'CpuPeriod'
),
1999
)
def
test_create_host_config_with_blkio_constraints
(
self
):
blkio_rate
=
[{
"Path"
:
"/dev/sda"
,
"Rate"
:
1000
}]
config
=
create_host_config
(
version
=
'1.22'
,
blkio_weight
=
1999
,
blkio_weight_device
=
blkio_rate
,
device_read_bps
=
blkio_rate
,
device_write_bps
=
blkio_rate
,
device_read_iops
=
blkio_rate
,
device_write_iops
=
blkio_rate
)
self
.
assertEqual
(
config
.
get
(
'BlkioWeight'
),
1999
)
self
.
assertTrue
(
config
.
get
(
'BlkioWeightDevice'
)
is
blkio_rate
)
self
.
assertTrue
(
config
.
get
(
'BlkioDeviceReadBps'
)
is
blkio_rate
)
self
.
assertTrue
(
config
.
get
(
'BlkioDeviceWriteBps'
)
is
blkio_rate
)
self
.
assertTrue
(
config
.
get
(
'BlkioDeviceReadIOps'
)
is
blkio_rate
)
self
.
assertTrue
(
config
.
get
(
'BlkioDeviceWriteIOps'
)
is
blkio_rate
)
self
.
assertEqual
(
blkio_rate
[
0
][
'Path'
],
"/dev/sda"
)
self
.
assertEqual
(
blkio_rate
[
0
][
'Rate'
],
1000
)
def
test_create_host_config_with_shm_size
(
self
):
config
=
create_host_config
(
version
=
'1.22'
,
shm_size
=
67108864
)
self
.
assertEqual
(
config
.
get
(
'ShmSize'
),
67108864
)
...
...
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