Просмотр исходного кода

Support for rollback config in compose 3.7

Ignoring it on docker-compose

Signed-off-by: Vincent Demeester <[email protected]>
Vincent Demeester 7 лет назад
Родитель
Сommit
70574efd5b

+ 2 - 1
compose/config/config.py

@@ -928,7 +928,7 @@ def translate_deploy_keys_to_container_config(service_dict):
 
     deploy_dict = service_dict['deploy']
     ignored_keys = [
-        k for k in ['endpoint_mode', 'labels', 'update_config', 'placement']
+        k for k in ['endpoint_mode', 'labels', 'update_config', 'rollback_config', 'placement']
         if k in deploy_dict
     ]
 
@@ -1136,6 +1136,7 @@ def merge_deploy(base, override):
     md.merge_scalar('replicas')
     md.merge_mapping('labels', parse_labels)
     md.merge_mapping('update_config')
+    md.merge_mapping('rollback_config')
     md.merge_mapping('restart_policy')
     if md.needs_merge('resources'):
         resources_md = MergeDict(md.base.get('resources') or {}, md.override.get('resources') or {})

+ 14 - 0
compose/config/config_schema_v3.7.json

@@ -348,6 +348,20 @@
         "endpoint_mode": {"type": "string"},
         "replicas": {"type": "integer"},
         "labels": {"$ref": "#/definitions/list_or_dict"},
+        "rollback_config": {
+          "type": "object",
+          "properties": {
+            "parallelism": {"type": "integer"},
+            "delay": {"type": "string", "format": "duration"},
+            "failure_action": {"type": "string"},
+            "monitor": {"type": "string", "format": "duration"},
+            "max_failure_ratio": {"type": "number"},
+            "order": {"type": "string", "enum": [
+              "start-first", "stop-first"
+            ]}
+          },
+          "additionalProperties": false
+        },
         "update_config": {
           "type": "object",
           "properties": {

+ 2 - 0
compose/config/interpolation.py

@@ -248,6 +248,8 @@ class ConversionMap(object):
         service_path('deploy', 'replicas'): to_int,
         service_path('deploy', 'update_config', 'parallelism'): to_int,
         service_path('deploy', 'update_config', 'max_failure_ratio'): to_float,
+        service_path('deploy', 'rollback_config', 'parallelism'): to_int,
+        service_path('deploy', 'rollback_config', 'max_failure_ratio'): to_float,
         service_path('deploy', 'restart_policy', 'max_attempts'): to_int,
         service_path('mem_swappiness'): to_int,
         service_path('labels', FULL_JOKER): to_str,

+ 1 - 1
compose/const.py

@@ -69,5 +69,5 @@ API_VERSION_TO_ENGINE_VERSION = {
     API_VERSIONS[COMPOSEFILE_V3_4]: '17.06.0',
     API_VERSIONS[COMPOSEFILE_V3_5]: '17.06.0',
     API_VERSIONS[COMPOSEFILE_V3_6]: '18.02.0',
-    API_VERSIONS[COMPOSEFILE_V3_7]: '18.02.0',
+    API_VERSIONS[COMPOSEFILE_V3_7]: '18.06.0',
 }