summaryrefslogtreecommitdiffstats
path: root/docker
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-09-12 04:22:22 +0000
committerGerrit Code Review <review@openstack.org>2017-09-12 04:22:22 +0000
commit06c7fb997366217de328f4af6428deebd7a21672 (patch)
treefaa272f8623e33532799a6fc08fbcf36c1b36afd /docker
parent506e1bb23c1ef18b85c9611490089c55d6a0eb8d (diff)
parent9a1015581d59a7a38e1bdb2ff97da1161123e05c (diff)
Merge "Add a docker pull retry to docker-puppet.py" into stable/pike
Diffstat (limited to 'docker')
-rwxr-xr-xdocker/docker-puppet.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/docker/docker-puppet.py b/docker/docker-puppet.py
index 0451ed51..cc247031 100755
--- a/docker/docker-puppet.py
+++ b/docker/docker-puppet.py
@@ -26,6 +26,7 @@ import sys
import subprocess
import sys
import tempfile
+import time
import multiprocessing
logger = None
@@ -59,10 +60,23 @@ def short_hostname():
def pull_image(name):
log.info('Pulling image: %s' % name)
- subproc = subprocess.Popen(['/usr/bin/docker', 'pull', name],
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
- cmd_stdout, cmd_stderr = subproc.communicate()
+ retval = -1
+ count = 0
+ while retval != 0:
+ count += 1
+ subproc = subprocess.Popen(['/usr/bin/docker', 'pull', name],
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+
+ cmd_stdout, cmd_stderr = subproc.communicate()
+ retval = subproc.returncode
+ if retval != 0:
+ time.sleep(3)
+ log.warning('docker pull failed: %s' % cmd_stderr)
+ log.warning('retrying pulling image: %s' % name)
+ if count >= 5:
+ log.error('Failed to pull image: %s' % name)
+ break
if cmd_stdout:
log.debug(cmd_stdout)
if cmd_stderr: