From a6fab9c48fba19170feeb5f63123a56e4cb1b5ac Mon Sep 17 00:00:00 2001 From: Thierry Carrez Date: Fri, 26 Jun 2020 13:11:49 +0200 Subject: [PATCH] upload-git-mirror: use retries to avoid races To avoid errors in case of mirror race conditions, we currently (try to) ignore mirror errors, and check for presence of the reference after the mirror try. This requires having to play tricks to avoid errors when the job is run in the check pipeline, due to missing zuul.newrev. And for some reason, it does not seem to work[1]. Instead of ignoring errors and running an additional check, let's just retry the mirror operation three times. The race is rare-enough that it's very unlikely that we would hit it three times in a row. [1] https://zuul.openstack.org/build/4966cd5617624d348fa0048de14f1f96 Change-Id: Ifa4f25ad8c961a1b2dbd9f07a3a1e4652b790c9c --- roles/upload-git-mirror/tasks/main.yaml | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/roles/upload-git-mirror/tasks/main.yaml b/roles/upload-git-mirror/tasks/main.yaml index 3965c5cdf..1de834b4d 100644 --- a/roles/upload-git-mirror/tasks/main.yaml +++ b/roles/upload-git-mirror/tasks/main.yaml @@ -38,15 +38,10 @@ chdir: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}" tags: - skip_ansible_lint - ignore_errors: zuul.newrev is defined - - - name: Check if the mirror contains the desired reference - command: git fetch {{ git_mirror_credentials.user }}@{{ git_mirror_credentials.host }}:{{ git_mirror_repository }} {{ zuul.newrev }} - args: - chdir: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}" - tags: - - skip_ansible_lint - when: zuul.newrev is defined + register: result + retries: 3 + delay: 5 + until: result is not failed always: # Registered variables below are only used for integration testing