From 454b5349b01ca31bb43afd0150ae1cafbe0db7a3 Mon Sep 17 00:00:00 2001
From: Monty Taylor <mordred@inaugust.com>
Date: Thu, 25 Apr 2019 17:19:25 +0000
Subject: [PATCH] Add retries to skopeo copy operations

We think that sometimes the network derps so the whole copy goes
bad. Add retries in to the mix since a copy command is idempotent.

Change-Id: I2d2891f2ebe3ca6a99874d9cf028addea888c3b7
---
 roles/pull-from-intermediate-registry/tasks/main.yaml     | 3 +++
 roles/push-to-intermediate-registry/tasks/push-image.yaml | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/roles/pull-from-intermediate-registry/tasks/main.yaml b/roles/pull-from-intermediate-registry/tasks/main.yaml
index 7caa3758d..75c4fdac8 100644
--- a/roles/pull-from-intermediate-registry/tasks/main.yaml
+++ b/roles/pull-from-intermediate-registry/tasks/main.yaml
@@ -74,6 +74,9 @@
         skopeo --insecure-policy copy
         {{ item.url }}
         docker://127.0.0.1:{{ socat_port }}/{{ item.metadata.repository }}:{{ item.metadata.tag }}
+      retries: 3
+      register: result
+      until: result is success
       when: "'metadata' in item and item.metadata.type | default('') == 'container_image'"
       loop: "{{ zuul.artifacts | default([]) }}"
   always:
diff --git a/roles/push-to-intermediate-registry/tasks/push-image.yaml b/roles/push-to-intermediate-registry/tasks/push-image.yaml
index a1a2e28c8..eba18a975 100644
--- a/roles/push-to-intermediate-registry/tasks/push-image.yaml
+++ b/roles/push-to-intermediate-registry/tasks/push-image.yaml
@@ -3,6 +3,9 @@
     skopeo --insecure-policy copy
     docker://127.0.0.1:{{ socat_port }}/{{ image.repository }}:{{ image_tag }}
     docker://{{ intermediate_registry.host | ipwrap }}:{{ intermediate_registry.port}}/{{ image.repository }}:{{ zuul.build }}_{{ image_tag }}
+  retries: 3
+  register: result
+  until: result is success
   loop: "{{ image.tags | default(['latest']) }}"
   loop_control:
     loop_var: image_tag