@@ -62,10 +62,24 @@ def create_service(
6262 'Labels' : labels ,
6363 'TaskTemplate' : task_template ,
6464 'Mode' : mode ,
65- 'UpdateConfig' : update_config ,
6665 'Networks' : utils .convert_service_networks (networks ),
6766 'EndpointSpec' : endpoint_spec
6867 }
68+
69+ if update_config is not None :
70+ if utils .version_lt (self ._version , '1.25' ):
71+ if 'MaxFailureRatio' in update_config :
72+ raise errors .InvalidVersion (
73+ 'UpdateConfig.max_failure_ratio is not supported in'
74+ ' API version < 1.25'
75+ )
76+ if 'Monitor' in update_config :
77+ raise errors .InvalidVersion (
78+ 'UpdateConfig.monitor is not supported in'
79+ ' API version < 1.25'
80+ )
81+ data ['UpdateConfig' ] = update_config
82+
6983 return self ._result (
7084 self ._post_json (url , data = data , headers = headers ), True
7185 )
@@ -230,6 +244,12 @@ def update_service(self, service, version, task_template=None, name=None,
230244 mode = ServiceMode (mode )
231245 data ['Mode' ] = mode
232246 if task_template is not None :
247+ if 'ForceUpdate' in task_template and utils .version_lt (
248+ self ._version , '1.25' ):
249+ raise errors .InvalidVersion (
250+ 'force_update is not supported in API version < 1.25'
251+ )
252+
233253 image = task_template .get ('ContainerSpec' , {}).get ('Image' , None )
234254 if image is not None :
235255 registry , repo_name = auth .resolve_repository_name (image )
@@ -238,7 +258,19 @@ def update_service(self, service, version, task_template=None, name=None,
238258 headers ['X-Registry-Auth' ] = auth_header
239259 data ['TaskTemplate' ] = task_template
240260 if update_config is not None :
261+ if utils .version_lt (self ._version , '1.25' ):
262+ if 'MaxFailureRatio' in update_config :
263+ raise errors .InvalidVersion (
264+ 'UpdateConfig.max_failure_ratio is not supported in'
265+ ' API version < 1.25'
266+ )
267+ if 'Monitor' in update_config :
268+ raise errors .InvalidVersion (
269+ 'UpdateConfig.monitor is not supported in'
270+ ' API version < 1.25'
271+ )
241272 data ['UpdateConfig' ] = update_config
273+
242274 if networks is not None :
243275 data ['Networks' ] = utils .convert_service_networks (networks )
244276 if endpoint_spec is not None :
0 commit comments