From d132d708e978511b49fd4cc4fdf9ee74dd457539 Mon Sep 17 00:00:00 2001 From: "Wahlstedt, Walter (ww229g)" Date: Tue, 21 Feb 2023 12:13:04 -0500 Subject: [PATCH] Docker log collection Collect logs for zuul jobs that use docker Change-Id: I8da05be5e84c0d565655721c4545ca7446794858 --- roles/gather-host-logs/tasks/main.yaml | 7 +++++++ roles/gather-pod-logs/tasks/main.yaml | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/roles/gather-host-logs/tasks/main.yaml b/roles/gather-host-logs/tasks/main.yaml index 5b04a446b..8031f9d68 100644 --- a/roles/gather-host-logs/tasks/main.yaml +++ b/roles/gather-host-logs/tasks/main.yaml @@ -29,6 +29,13 @@ brctl show > {{ logs_dir }}/system/brctl-show.txt ps aux --sort=-%mem > {{ logs_dir }}/system/ps.txt dpkg -l > {{ logs_dir }}/system/packages.txt + CONTAINERS=($(docker ps -a --format {% raw %}'{{ .Names }}'{% endraw %} --filter label=zuul)) + if [ ! -z "$CONTAINERS" ]; then + mkdir -p "{{ logs_dir }}/system/containers" + for CONTAINER in ${CONTAINERS}; do + docker logs "${CONTAINER}" > "{{ logs_dir }}/system/containers/${CONTAINER}.txt" + done + fi args: executable: /bin/bash ignore_errors: True diff --git a/roles/gather-pod-logs/tasks/main.yaml b/roles/gather-pod-logs/tasks/main.yaml index 373f5a0a5..d3a3a794c 100644 --- a/roles/gather-pod-logs/tasks/main.yaml +++ b/roles/gather-pod-logs/tasks/main.yaml @@ -21,7 +21,7 @@ path: "{{ logs_dir }}/pod-logs/failed-pods" state: directory -- name: "retrieve all container logs, current and previous (if they exist)" +- name: "retrieve all kubernetes logs, current and previous (if they exist)" shell: |- set -e PARALLELISM_FACTOR=2