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
042c7054
Kaydet (Commit)
042c7054
authored
Agu 04, 2016
tarafından
Jamie Greeff
Kaydeden (comit)
Joffrey F
Ara 08, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add support for passing healthcheck to create_container
Signed-off-by:
Jamie Greeff
<
jamie@greeff.me
>
üst
aa282f37
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
95 additions
and
4 deletions
+95
-4
container.py
docker/api/container.py
+4
-3
__init__.py
docker/types/__init__.py
+1
-0
healthcheck.py
docker/types/healthcheck.py
+47
-0
utils.py
docker/utils/utils.py
+8
-1
healthcheck_test.py
tests/integration/healthcheck_test.py
+35
-0
No files found.
docker/api/container.py
Dosyayı görüntüle @
042c7054
...
...
@@ -115,7 +115,8 @@ class ContainerApiMixin(object):
cpu_shares
=
None
,
working_dir
=
None
,
domainname
=
None
,
memswap_limit
=
None
,
cpuset
=
None
,
host_config
=
None
,
mac_address
=
None
,
labels
=
None
,
volume_driver
=
None
,
stop_signal
=
None
,
networking_config
=
None
):
stop_signal
=
None
,
networking_config
=
None
,
healthcheck
=
None
):
if
isinstance
(
volumes
,
six
.
string_types
):
volumes
=
[
volumes
,
]
...
...
@@ -130,7 +131,7 @@ class ContainerApiMixin(object):
tty
,
mem_limit
,
ports
,
environment
,
dns
,
volumes
,
volumes_from
,
network_disabled
,
entrypoint
,
cpu_shares
,
working_dir
,
domainname
,
memswap_limit
,
cpuset
,
host_config
,
mac_address
,
labels
,
volume_driver
,
stop_signal
,
networking_config
,
volume_driver
,
stop_signal
,
networking_config
,
healthcheck
,
)
return
self
.
create_container_from_config
(
config
,
name
)
...
...
@@ -365,7 +366,7 @@ class ContainerApiMixin(object):
cap_drop
=
cap_drop
,
volumes_from
=
volumes_from
,
devices
=
devices
,
network_mode
=
network_mode
,
restart_policy
=
restart_policy
,
extra_hosts
=
extra_hosts
,
read_only
=
read_only
,
pid_mode
=
pid_mode
,
ipc_mode
=
ipc_mode
,
security_opt
=
security_opt
,
ulimits
=
ulimits
ipc_mode
=
ipc_mode
,
security_opt
=
security_opt
,
ulimits
=
ulimits
,
)
start_config
=
None
...
...
docker/types/__init__.py
Dosyayı görüntüle @
042c7054
...
...
@@ -4,4 +4,5 @@ from .services import (
ContainerSpec
,
DriverConfig
,
EndpointSpec
,
Mount
,
Resources
,
RestartPolicy
,
TaskTemplate
,
UpdateConfig
)
from
.healthcheck
import
Healthcheck
from
.swarm
import
SwarmSpec
,
SwarmExternalCA
docker/types/healthcheck.py
0 → 100644
Dosyayı görüntüle @
042c7054
from
.base
import
DictType
class
Healthcheck
(
DictType
):
def
__init__
(
self
,
**
kwargs
):
test
=
kwargs
.
get
(
'test'
,
kwargs
.
get
(
'Test'
))
interval
=
kwargs
.
get
(
'interval'
,
kwargs
.
get
(
'Interval'
))
timeout
=
kwargs
.
get
(
'timeout'
,
kwargs
.
get
(
'Timeout'
))
retries
=
kwargs
.
get
(
'retries'
,
kwargs
.
get
(
'Retries'
))
super
(
Healthcheck
,
self
)
.
__init__
({
'Test'
:
test
,
'Interval'
:
interval
,
'Timeout'
:
timeout
,
'Retries'
:
retries
})
@property
def
test
(
self
):
return
self
[
'Test'
]
@test.setter
def
test
(
self
,
value
):
self
[
'Test'
]
=
value
@property
def
interval
(
self
):
return
self
[
'Interval'
]
@interval.setter
def
interval
(
self
,
value
):
self
[
'Interval'
]
=
value
@property
def
timeout
(
self
):
return
self
[
'Timeout'
]
@timeout.setter
def
timeout
(
self
,
value
):
self
[
'Timeout'
]
=
value
@property
def
retries
(
self
):
return
self
[
'Retries'
]
@retries.setter
def
retries
(
self
,
value
):
self
[
'Retries'
]
=
value
docker/utils/utils.py
Dosyayı görüntüle @
042c7054
...
...
@@ -1041,6 +1041,7 @@ def create_container_config(
entrypoint
=
None
,
cpu_shares
=
None
,
working_dir
=
None
,
domainname
=
None
,
memswap_limit
=
None
,
cpuset
=
None
,
host_config
=
None
,
mac_address
=
None
,
labels
=
None
,
volume_driver
=
None
,
stop_signal
=
None
,
networking_config
=
None
,
healthcheck
=
None
,
):
if
isinstance
(
command
,
six
.
string_types
):
command
=
split_command
(
command
)
...
...
@@ -1069,6 +1070,11 @@ def create_container_config(
'stop_signal was only introduced in API version 1.21'
)
if
healthcheck
is
not
None
and
version_lt
(
version
,
'1.24'
):
raise
errors
.
InvalidVersion
(
'Health options were only introduced in API version 1.24'
)
if
compare_version
(
'1.19'
,
version
)
<
0
:
if
volume_driver
is
not
None
:
raise
errors
.
InvalidVersion
(
...
...
@@ -1176,5 +1182,6 @@ def create_container_config(
'MacAddress'
:
mac_address
,
'Labels'
:
labels
,
'VolumeDriver'
:
volume_driver
,
'StopSignal'
:
stop_signal
'StopSignal'
:
stop_signal
,
'Healthcheck'
:
healthcheck
,
}
tests/integration/healthcheck_test.py
0 → 100644
Dosyayı görüntüle @
042c7054
import
time
import
docker
from
..base
import
requires_api_version
from
..
import
helpers
class
HealthcheckTest
(
helpers
.
BaseTestCase
):
@requires_api_version
(
'1.21'
)
def
test_healthcheck
(
self
):
healthcheck
=
docker
.
types
.
Healthcheck
(
test
=
[
"CMD-SHELL"
,
"foo.txt || (/bin/usleep 10000 && touch foo.txt)"
],
interval
=
500000
,
timeout
=
1000000000
,
retries
=
1
)
container
=
self
.
client
.
create_container
(
helpers
.
BUSYBOX
,
'cat'
,
detach
=
True
,
stdin_open
=
True
,
healthcheck
=
healthcheck
)
id
=
container
[
'Id'
]
self
.
client
.
start
(
id
)
self
.
tmp_containers
.
append
(
id
)
res1
=
self
.
client
.
inspect_container
(
id
)
self
.
assertIn
(
'State'
,
res1
)
self
.
assertIn
(
'Health'
,
res1
[
'State'
])
self
.
assertIn
(
'Status'
,
res1
[
'State'
][
'Health'
])
self
.
assertEqual
(
res1
[
'State'
][
'Health'
][
'Status'
],
"starting"
)
time
.
sleep
(
0.5
)
res2
=
self
.
client
.
inspect_container
(
id
)
self
.
assertIn
(
'State'
,
res2
)
self
.
assertIn
(
'Health'
,
res2
[
'State'
])
self
.
assertIn
(
'Status'
,
res2
[
'State'
][
'Health'
])
self
.
assertEqual
(
res2
[
'State'
][
'Health'
][
'Status'
],
"healthy"
)
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