collect-container-logs: don't copy on failure
After a docker failure on a recent job I noticed a single file called "Got" in the container logs directory; turns out this had tried to parse the error message "Got permission denied while trying to connect to the Docker daemon socket ..." as containers. We don't want this to fail the job hence the ignores here. However, we shouldn't try to collect any logs if listing the containers fails. Move creating the directory first as that is safe. Change-Id: I41db956964f695cfcc15e30cab8cd4f8c31d3706
This commit is contained in:
parent
90c103eaad
commit
9b17d6c9df
@ -1,14 +1,14 @@
|
|||||||
- name: List containers
|
|
||||||
command: "{{ container_command }} ps -a --format '{{ '{{ .Names }}' }}'"
|
|
||||||
register: docker_containers
|
|
||||||
failed_when: false
|
|
||||||
|
|
||||||
- name: Create container log dir
|
- name: Create container log dir
|
||||||
file:
|
file:
|
||||||
path: "{{ ansible_user_dir }}/zuul-output/logs/{{ container_command }}"
|
path: "{{ ansible_user_dir }}/zuul-output/logs/{{ container_command }}"
|
||||||
state: directory
|
state: directory
|
||||||
mode: 0755
|
mode: 0755
|
||||||
|
|
||||||
|
- name: List containers
|
||||||
|
command: "{{ container_command }} ps -a --format '{{ '{{ .Names }}' }}'"
|
||||||
|
register: docker_containers
|
||||||
|
failed_when: false
|
||||||
|
|
||||||
- name: Save container logs
|
- name: Save container logs
|
||||||
loop: "{{ docker_containers.stdout_lines | default([]) }}"
|
loop: "{{ docker_containers.stdout_lines | default([]) }}"
|
||||||
# We can't use the default 'item' because roles may be used in
|
# We can't use the default 'item' because roles may be used in
|
||||||
@ -19,6 +19,7 @@
|
|||||||
args:
|
args:
|
||||||
executable: /bin/bash
|
executable: /bin/bash
|
||||||
failed_when: false
|
failed_when: false
|
||||||
|
when: docker_containers.rc == 0
|
||||||
|
|
||||||
- name: Open container logs permissions
|
- name: Open container logs permissions
|
||||||
file:
|
file:
|
||||||
|
Loading…
Reference in New Issue
Block a user