From a5f50918979a790686862bc2f6b2174a8a61bb9e Mon Sep 17 00:00:00 2001 From: Albin Vass Date: Tue, 28 Apr 2020 20:55:30 +0200 Subject: [PATCH] Revert "Revert "Do not set buildset_fact if it's not present in results.json"" This reverts commit b5e87e62f1ff03dd80067aa1ec297007770301ce. Change-Id: I839c0fb9811ce68e2949402f12aab1387d1a812e --- roles/build-container-image/tasks/main.yaml | 13 +++++++++++-- roles/build-docker-image/tasks/main.yaml | 13 +++++++++++-- roles/collect-container-logs/tasks/main.yaml | 2 +- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/roles/build-container-image/tasks/main.yaml b/roles/build-container-image/tasks/main.yaml index 42dfd716a..fdc685dac 100644 --- a/roles/build-container-image/tasks/main.yaml +++ b/roles/build-container-image/tasks/main.yaml @@ -1,9 +1,18 @@ +- name: Check for results.json + stat: + path: "{{ zuul.executor.work_root }}/results.json" + register: result_json_stat + delegate_to: localhost + # This can be removed if we add this functionality to Zuul directly - name: Load information from zuul_return - when: buildset_registry is not defined set_fact: buildset_registry: "{{ (lookup('file', zuul.executor.work_root + '/results.json') | from_json)['buildset_registry'] }}" - ignore_errors: true + when: + - buildset_registry is not defined + - result_json_stat.stat.exists + - result_json_stat.stat.size > 0 + - "'buildset_registry' in (lookup('file', zuul.executor.work_root + '/results.json') | from_json)" - name: Set container filename arg set_fact: diff --git a/roles/build-docker-image/tasks/main.yaml b/roles/build-docker-image/tasks/main.yaml index c5d089880..1cbcce661 100644 --- a/roles/build-docker-image/tasks/main.yaml +++ b/roles/build-docker-image/tasks/main.yaml @@ -1,9 +1,18 @@ +- name: Check for results.json + stat: + path: "{{ zuul.executor.work_root }}/results.json" + register: result_json_stat + delegate_to: localhost + # This can be removed if we add this functionality to Zuul directly - name: Load information from zuul_return - when: buildset_registry is not defined set_fact: buildset_registry: "{{ (lookup('file', zuul.executor.work_root + '/results.json') | from_json)['buildset_registry'] }}" - ignore_errors: true + when: + - buildset_registry is not defined + - result_json_stat.stat.exists + - result_json_stat.stat.size > 0 + - "'buildset_registry' in (lookup('file', zuul.executor.work_root + '/results.json') | from_json)" - name: Build docker images include_tasks: build.yaml diff --git a/roles/collect-container-logs/tasks/main.yaml b/roles/collect-container-logs/tasks/main.yaml index 08e79c8d4..d5a3e8fb7 100644 --- a/roles/collect-container-logs/tasks/main.yaml +++ b/roles/collect-container-logs/tasks/main.yaml @@ -1,7 +1,7 @@ - name: List containers command: "{{ container_command }} ps -a --format '{{ '{{ .Names }}' }}'" register: docker_containers - ignore_errors: true + failed_when: false - name: Create container log dir file: