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
(cherry picked from commit d160d8c4b0
)
This commit is contained in:
parent
80858ce0a0
commit
ad1f8a2dec
|
@ -92,11 +92,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:
|
||||
|
|
Loading…
Reference in New Issue