Save failed logs to haste

pull/680/head
Erik Wilson 2019-07-26 15:10:39 -07:00
parent 1833b65fcd
commit de8b811ff6
1 changed files with 19 additions and 5 deletions

View File

@ -87,13 +87,25 @@ export -f wait-for-services
# --- # ---
haste() {
a=$(cat)
curl -X POST -s -d "$a" https://hastebin.com/documents | \
awk -F '"' '{print "https://hastebin.com/"$4}'
}
export -f haste
# ---
dump-container-logs() { dump-container-logs() {
set +xe
set -v
for container in ${CONTAINERS}; do for container in ${CONTAINERS}; do
docker cp ${container}:/var/lib/rancher/k3s/agent/containerd/containerd.log ${OUTPUT}/${container}-containerd.log echo "logs for container: ${container}"
docker logs ${container} >${OUTPUT}/${container}.log 2>&1 echo " k3s service log: "$(docker logs ${container} 2>&1 | haste)
cat ${OUTPUT}/${container}-containerd.log echo " containerd logs: "$(docker cp ${container}:/var/lib/rancher/k3s/agent/containerd/containerd.log - | haste)
cat ${OUTPUT}/${container}.log
done done
set +v
set -xe
} }
export -f dump-container-logs export -f dump-container-logs
@ -144,7 +156,6 @@ sonobuoy-retry-test() {
break break
fi fi
done done
dump-container-logs
return 1 return 1
} }
export -f sonobuoy-retry-test export -f sonobuoy-retry-test
@ -155,6 +166,9 @@ cleanup() {
exit_status=$? exit_status=$?
set +e set +e
echo "Cleaning up" echo "Cleaning up"
if [ "${exit_status}" -ne "0" ]; then
dump-container-logs
fi
docker rm -f ${CONTAINERS} 2>/dev/null docker rm -f ${CONTAINERS} 2>/dev/null
rm ${KUBECONFIG} rm ${KUBECONFIG}
exit ${exit_status} exit ${exit_status}