From d160d8c4b0e54dcb0089c859335415f6fa99d6cd Mon Sep 17 00:00:00 2001 From: Emilien Macchi Date: Tue, 19 May 2020 08:44:20 -0400 Subject: [PATCH] podman/create: make containers_to_check more realistic containers_to_check is a list of containers that run something and then exit with a return code. Later we will check what their return code is and make sure the containers didn't fail before we continue with the deployment. Also, if a container failed to be created or updated; we don't want to include it in the list that contains the containers in which we want to check if the returned RC is valid; since we already know the container didn't terminate correctly. Closes-Bug: #1878405 Change-Id: Ia3a985d923c5f44babaae601f3ba62b6d48659da --- .../tasks/podman/create.yml | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/tripleo_ansible/roles/tripleo_container_manage/tasks/podman/create.yml b/tripleo_ansible/roles/tripleo_container_manage/tasks/podman/create.yml index eac971d3b..9a11f53c7 100644 --- a/tripleo_ansible/roles/tripleo_container_manage/tasks/podman/create.yml +++ b/tripleo_ansible/roles/tripleo_container_manage/tasks/podman/create.yml @@ -97,11 +97,24 @@ when: - not ansible_check_mode|bool -- name: "Create facts for containers which changed or failed or which require rc check" +- name: "Create fact for containers which changed" set_fact: - containers_changed: "{{ create_async_poll_results.results | get_changed_containers }}" - containers_failed: "{{ create_async_poll_results.results | get_failed_containers }}" - containers_to_check: "{{ batched_container_data | haskey(attribute='command', excluded_keys=['action', 'restart']) | list_of_keys | default([]) }}" + # List of containers which have changed (created or updated) + containers_changed: "{{ create_async_poll_results.results | get_changed_containers | default([]) }}" + +- name: "Create fact for containers which failed" + set_fact: + # List of containers which returned an error when creating or updating them + containers_failed: "{{ create_async_poll_results.results | get_failed_containers | default([]) }}" + +- name: "Create fact for containers which require rc check" + set_fact: + # List of containers which would terminate with a return code that needs to be valid. + # We assume that container configs that don't have a restart policy nor action + # (used for podman exec) will run something and then exit with a return code. + containers_to_check: >- + {{ batched_container_data | haskey(attribute='image', excluded_keys=['action', 'restart']) | + list_of_keys | default([]) | difference(containers_failed) }} - name: Print the containers that failed to start fail: