@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: () -> None
+ logger.info('Pulling container image %s...' % image)
+
+ ignorelist = [
+ "error creating read-write layer with ID",
+ "net/http: TLS handshake timeout",
+ ]
+
+ 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)
##################################
config = cpf.getvalue()
if not args.skip_pull:
- logger.info('Pulling latest %s container...' % args.image)
- call_throws([container_path, 'pull', args.image])
+ _pull_image(args.image)
logger.info('Extracting ceph user uid/gid from container image...')
(uid, gid) = extract_uid_gid()
# type: () -> None
if not args.skip_pull:
- logger.info('Pulling latest %s container...' % args.image)
- call_throws([container_path, 'pull', args.image])
+ _pull_image(args.image)
(daemon_type, daemon_id) = args.name.split('.', 1)