mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
Merge pull request #682 from erikwilson/sonobuoy-logs-cleanup
Cleanup sonobuoy logging
This commit is contained in:
commit
4a65764c3b
@ -87,32 +87,20 @@ 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() {
|
||||
set +xe
|
||||
set -v
|
||||
mkdir -p ${LOGS}
|
||||
for container in ${CONTAINERS}; do
|
||||
echo "logs for container: ${container}"
|
||||
echo " k3s service log: "$(docker logs ${container} 2>&1 | haste)
|
||||
echo " containerd logs: "$(docker cp ${container}:/var/lib/rancher/k3s/agent/containerd/containerd.log - | haste)
|
||||
docker cp ${container}:/var/lib/rancher/k3s/agent/containerd/containerd.log ${LOGS}/containerd-${container}.log
|
||||
docker logs ${container} >${LOGS}/${container}.log 2>&1
|
||||
done
|
||||
set +v
|
||||
set -xe
|
||||
}
|
||||
export -f dump-container-logs
|
||||
|
||||
# ---
|
||||
|
||||
sonobuoy-destruct() {
|
||||
sonobuoy logs
|
||||
mkdir -p ${LOGS}
|
||||
sonobuoy logs >${LOGS}/$i-sonobuoy.log 2>&1
|
||||
sonobuoy delete --wait
|
||||
}
|
||||
export -f sonobuoy-destruct
|
||||
@ -179,6 +167,7 @@ trap cleanup EXIT
|
||||
|
||||
K3S_PORT=$(timeout --foreground 5s bash -c get-port)
|
||||
OUTPUT=$(pwd)/sonobuoy-output/${K3S_PORT}
|
||||
LOGS=$(pwd)/logs/$$
|
||||
E2E="${OUTPUT}/e2e"
|
||||
E2E_LOG="plugins/e2e/results/e2e.log"
|
||||
RESULTS="${E2E}/${E2E_LOG}"
|
||||
|
@ -3,15 +3,6 @@ set -e -x
|
||||
|
||||
cd $(dirname $0)/..
|
||||
|
||||
cleanup() {
|
||||
exit_code=$?
|
||||
set +e
|
||||
wait
|
||||
echo "Finished the tests!"
|
||||
exit ${exit_code}
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
if [ -z "$K3S_IMAGE" ]; then
|
||||
source $(dirname $0)/version.sh
|
||||
TAG=${TAG:-${VERSION}${SUFFIX}}
|
||||
@ -32,7 +23,6 @@ run-sonobuoy() {
|
||||
pids+=($!)
|
||||
}
|
||||
|
||||
|
||||
log_output=${OUTPUT}/e2e-STATUS-${ARCH}-parallel.log \
|
||||
run-sonobuoy --e2e-focus='\[Conformance\]' --e2e-skip='\[Serial\]' --e2e-parallel=y
|
||||
|
||||
@ -41,6 +31,39 @@ sleep 60
|
||||
log_output=${OUTPUT}/e2e-STATUS-${ARCH}-serial.log \
|
||||
run-sonobuoy --e2e-focus='\[Serial\].*\[Conformance\]'
|
||||
|
||||
show-logs() {
|
||||
for pid in "${pids[@]}"; do
|
||||
logdir=$(pwd)/logs/${pid}
|
||||
if [ ! -d $logdir ]; then
|
||||
continue
|
||||
fi
|
||||
echo
|
||||
echo "#- Begin: logs for sonobuoy run pid ${pid}"
|
||||
for log in $(pwd)/logs/${pid}/*; do
|
||||
if [ -f ${log} ]; then
|
||||
echo
|
||||
echo "#- Start: ${log}"
|
||||
cat ${log}
|
||||
echo "#- End: ${log}"
|
||||
echo
|
||||
fi
|
||||
done
|
||||
echo "#- Finish: logs for sonobuoy run pid ${pid}"
|
||||
echo
|
||||
done
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
exit_status=$?
|
||||
set +e +x
|
||||
wait
|
||||
echo "Finished the tests!"
|
||||
if [ "${exit_status}" -ne "0" ]; then
|
||||
show-logs
|
||||
fi
|
||||
exit ${exit_status}
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
for pid in "${pids[@]}"; do
|
||||
wait $pid || exit $?
|
||||
|
Loading…
Reference in New Issue
Block a user