From e53fe850c86ac328e64b224eae194631f4bad974 Mon Sep 17 00:00:00 2001 From: Thierry Carrez Date: Tue, 23 Jun 2020 14:49:37 +0200 Subject: [PATCH] upload-git-mirror: check after mirror operation The upload-git-mirror job currently reports failure when multiple jobs run concurrently for the same repository (one of them succeeds, the other fails because the state of the mirror was changed by the successful one). However, since the job generally runs a few minutes after the commit that triggered it merged, the successful job usually mirrored the two needed commits, so the failed mirror operation does not mean the mirror is out-of-sync. This results in false negatives. If zuul.newrev is provided, rather than report failure if the mirror operation fails, we should report failure if, after the mirror operation, the commit that triggered the job is still not present on the mirror. Change-Id: Iadae26473f4c937384c8cea74329e389c563aeed --- roles/upload-git-mirror/tasks/main.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/roles/upload-git-mirror/tasks/main.yaml b/roles/upload-git-mirror/tasks/main.yaml index 4c3ee9203..3965c5cdf 100644 --- a/roles/upload-git-mirror/tasks/main.yaml +++ b/roles/upload-git-mirror/tasks/main.yaml @@ -38,6 +38,16 @@ 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 + always: # Registered variables below are only used for integration testing - name: Remove SSH private key from disk