]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Merge pull request #35846 from sebastian-philipp/podman-pull-retry
authorSebastian Wagner <sebastian.wagner@suse.com>
Fri, 17 Jul 2020 11:02:27 +0000 (13:02 +0200)
committerGitHub <noreply@github.com>
Fri, 17 Jul 2020 11:02:27 +0000 (13:02 +0200)
cephadm: Retry pull on transient error

Reviewed-by: Ricardo Marques <rimarques@suse.com>
1  2 
src/cephadm/cephadm

index 19235ed6113bdde2e21a26273ca84af85ac087d5,13511000e279a0155340fd07865fa4628b65720e..c74f87b4d214f6dcbaccbb47fdc4441e952b3f3f
@@@ -2395,13 -2293,38 +2395,39 @@@ def command_version()
  @infer_image
  def command_pull():
      # type: () -> int
-     logger.info('Pulling latest %s...' % args.image)
-     call_throws([container_path, 'pull', args.image])
+     _pull_image(args.image)
      return command_inspect_image()
  
+ def _pull_image(image):
+     # type: (str) -> None
+     logger.info('Pulling container image %s...' % image)
+     ignorelist = [
+         "error creating read-write layer with ID",
+         "net/http: TLS handshake timeout",
+         "Digest did not match, expected",
+     ]
+     cmd = [container_path, 'pull', image]
+     cmd_str = ' '.join(cmd)
+     for sleep_secs in [1, 4, 25]:
+         out, err, ret = call(cmd)
+         if not ret:
+             return
+         if not any(pattern in err for pattern in ignorelist):
+             raise RuntimeError('Failed command: %s' % cmd_str)
+         logger.info('"%s failed transiently. Retrying. waiting %s seconds...' % (cmd_str, sleep_secs))
+         time.sleep(sleep_secs)
+     raise RuntimeError('Failed command: %s: maximum retries reached' % cmd_str)
  ##################################
  
 +
  @infer_image
  def command_inspect_image():
      # type: () -> int