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
fc5cd1a9
Kaydet (Commit)
fc5cd1a9
authored
Ock 28, 2017
tarafından
Joffrey F
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add support for max_failure_ratio and monitor in UpdateConfig
Signed-off-by:
Joffrey F
<
joffrey@docker.com
>
üst
d1b51c39
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
1 deletion
+38
-1
services.py
docker/types/services.py
+21
-1
api_service_test.py
tests/integration/api_service_test.py
+17
-0
No files found.
docker/types/services.py
Dosyayı görüntüle @
fc5cd1a9
...
...
@@ -233,8 +233,14 @@ class UpdateConfig(dict):
failure_action (string): Action to take if an updated task fails to
run, or stops running during the update. Acceptable values are
``continue`` and ``pause``. Default: ``continue``
monitor (int): Amount of time to monitor each updated task for
failures, in nanoseconds.
max_failure_ratio (float): The fraction of tasks that may fail during
an update before the failure action is invoked, specified as a
floating point number between 0 and 1. Default: 0
"""
def
__init__
(
self
,
parallelism
=
0
,
delay
=
None
,
failure_action
=
'continue'
):
def
__init__
(
self
,
parallelism
=
0
,
delay
=
None
,
failure_action
=
'continue'
,
monitor
=
None
,
max_failure_ratio
=
None
):
self
[
'Parallelism'
]
=
parallelism
if
delay
is
not
None
:
self
[
'Delay'
]
=
delay
...
...
@@ -244,6 +250,20 @@ class UpdateConfig(dict):
)
self
[
'FailureAction'
]
=
failure_action
if
monitor
is
not
None
:
if
not
isinstance
(
monitor
,
int
):
raise
TypeError
(
'monitor must be an integer'
)
self
[
'Monitor'
]
=
monitor
if
max_failure_ratio
is
not
None
:
if
not
isinstance
(
max_failure_ratio
,
(
float
,
int
)):
raise
TypeError
(
'max_failure_ratio must be a float'
)
if
max_failure_ratio
>
1
or
max_failure_ratio
<
0
:
raise
errors
.
InvalidArgument
(
'max_failure_ratio must be a number between 0 and 1'
)
self
[
'MaxFailureRatio'
]
=
max_failure_ratio
class
RestartConditionTypesEnum
(
object
):
_values
=
(
...
...
tests/integration/api_service_test.py
Dosyayı görüntüle @
fc5cd1a9
...
...
@@ -155,6 +155,23 @@ class ServiceTest(BaseAPIIntegrationTest):
assert
update_config
[
'Delay'
]
==
uc
[
'Delay'
]
assert
update_config
[
'FailureAction'
]
==
uc
[
'FailureAction'
]
@requires_api_version
(
'1.25'
)
def
test_create_service_with_update_config_monitor
(
self
):
container_spec
=
docker
.
types
.
ContainerSpec
(
'busybox'
,
[
'true'
])
task_tmpl
=
docker
.
types
.
TaskTemplate
(
container_spec
)
update_config
=
docker
.
types
.
UpdateConfig
(
monitor
=
300000000
,
max_failure_ratio
=
0.4
)
name
=
self
.
get_service_name
()
svc_id
=
self
.
client
.
create_service
(
task_tmpl
,
update_config
=
update_config
,
name
=
name
)
svc_info
=
self
.
client
.
inspect_service
(
svc_id
)
assert
'UpdateConfig'
in
svc_info
[
'Spec'
]
uc
=
svc_info
[
'Spec'
][
'UpdateConfig'
]
assert
update_config
[
'Monitor'
]
==
uc
[
'Monitor'
]
assert
update_config
[
'MaxFailureRatio'
]
==
uc
[
'MaxFailureRatio'
]
def
test_create_service_with_restart_policy
(
self
):
container_spec
=
docker
.
types
.
ContainerSpec
(
'busybox'
,
[
'true'
])
policy
=
docker
.
types
.
RestartPolicy
(
...
...
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