Gate: Gather previous pod logs for failed containers

This updates the post-run pod logs task to gather logs from any
failed containers, allowing for identifying issues associated with
pods that fail to start in the gate jobs

Change-Id: I9195f319a064f84f62d2aa558df05f8f81b9abea
This commit is contained in:
Steve Wilkerson 2018-09-17 15:50:47 -05:00 committed by Chris Wedgwood
parent 5e1ecd9840
commit cc8c78dd6c
1 changed files with 9 additions and 2 deletions

View File

@ -15,7 +15,12 @@
path: "{{ logs_dir }}/pod-logs"
state: directory
- name: "retrieve all container logs"
- name: "creating directory for failed pod logs"
file:
path: "{{ logs_dir }}/pod-logs/failed-pods"
state: directory
- name: "retrieve all container logs, current and previous (if they exist)"
shell: |-
set -e
PARALLELISM_FACTOR=2
@ -35,7 +40,9 @@
for CONTAINER in ${INIT_CONTAINERS} ${CONTAINERS}; do
echo "${NAMESPACE}/${POD}/${CONTAINER}"
mkdir -p "{{ logs_dir }}/pod-logs/${NAMESPACE}/${POD}"
mkdir -p "{{ logs_dir }}/pod-logs/failed-pods/${NAMESPACE}/${POD}"
kubectl logs ${POD} -n ${NAMESPACE} -c ${CONTAINER} > "{{ logs_dir }}/pod-logs/${NAMESPACE}/${POD}/${CONTAINER}.txt"
kubectl logs --previous ${POD} -n ${NAMESPACE} -c ${CONTAINER} > "{{ logs_dir }}/pod-logs/failed-pods/${NAMESPACE}/${POD}/${CONTAINER}.txt"
done
}
export -f get_pod_logs
@ -46,7 +53,7 @@
executable: /bin/bash
ignore_errors: True
- name: "Downloads logs to executor"
- name: "Downloads pod logs to executor"
synchronize:
src: "{{ logs_dir }}/pod-logs"
dest: "{{ zuul.executor.log_root }}/{{ inventory_hostname }}"