[2.7] docker_swarm_service: fix problem with UpdateConfig on certain docker daemons (#53224)

* Avoid KeyError when UpdateConfig isn't returned.

* Add changelog.
This commit is contained in:
Felix Fontein 2019-03-04 16:35:22 +01:00 committed by Toshio Kuratomi
parent 597db1dc28
commit 122e73d062
2 changed files with 11 additions and 7 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- "docker_swarm_service - fix problem with docker daemons which do not return ``UpdateConfig`` in the swarm service spec."

View file

@ -897,12 +897,14 @@ class DockerServiceManager():
ds = DockerService()
task_template_data = raw_data['Spec']['TaskTemplate']
update_config_data = raw_data['Spec']['UpdateConfig']
ds.image = task_template_data['ContainerSpec']['Image']
ds.user = task_template_data['ContainerSpec'].get('User', 'root')
ds.env = task_template_data['ContainerSpec'].get('Env', [])
ds.args = task_template_data['ContainerSpec'].get('Args', [])
update_config_data = raw_data['Spec'].get('UpdateConfig')
if update_config_data:
ds.update_delay = update_config_data['Delay']
ds.update_parallelism = update_config_data['Parallelism']
ds.update_failure_action = update_config_data['FailureAction']