From 69b985f1b62d3ca8bdce97c04c7ce761cb70261f Mon Sep 17 00:00:00 2001 From: Jeffrey Zhang Date: Fri, 20 Jan 2017 16:32:31 +0800 Subject: [PATCH] Fix docker restart policy issue on docker engine 1.13 Docker v1.25 api now validates restart policies[0] [0] https://github.com/docker/docker/blob/master/docs/api/version-history.md Change-Id: Idc90cb99cf38ab1e637568ee5dbe5adcb2fa5b78 Closes-Bug: #1657946 --- ansible/library/kolla_docker.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ansible/library/kolla_docker.py b/ansible/library/kolla_docker.py index 494ae5243f..4e731da7ad 100644 --- a/ansible/library/kolla_docker.py +++ b/ansible/library/kolla_docker.py @@ -523,10 +523,13 @@ class DockerWorker(object): if self.params.get('restart_policy') in ['on-failure', 'always', 'unless-stopped']: - options['restart_policy'] = { - 'Name': self.params.get('restart_policy'), - 'MaximumRetryCount': self.params.get('restart_retries') - } + policy = {'Name': self.params.get('restart_policy')} + # NOTE(Jeffrey4l): MaximumRetryCount is only needed for on-failure + # policy + if self.params.get('restart_policy') == 'on-failure': + retries = self.params.get('restart_retries') + policy['MaximumRetryCount'] = retries + options['restart_policy'] = policy if binds: options['binds'] = binds