mirror of https://github.com/k3s-io/k3s
Cleanup sonobuoy logging
parent
c86e95062a
commit
9452dec078
|
@ -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() {
|
dump-container-logs() {
|
||||||
set +xe
|
mkdir -p ${LOGS}
|
||||||
set -v
|
|
||||||
for container in ${CONTAINERS}; do
|
for container in ${CONTAINERS}; do
|
||||||
echo "logs for container: ${container}"
|
docker cp ${container}:/var/lib/rancher/k3s/agent/containerd/containerd.log ${LOGS}/containerd-${container}.log
|
||||||
echo " k3s service log: "$(docker logs ${container} 2>&1 | haste)
|
docker logs ${container} >${LOGS}/${container}.log 2>&1
|
||||||
echo " containerd logs: "$(docker cp ${container}:/var/lib/rancher/k3s/agent/containerd/containerd.log - | haste)
|
|
||||||
done
|
done
|
||||||
set +v
|
|
||||||
set -xe
|
|
||||||
}
|
}
|
||||||
export -f dump-container-logs
|
export -f dump-container-logs
|
||||||
|
|
||||||
# ---
|
# ---
|
||||||
|
|
||||||
sonobuoy-destruct() {
|
sonobuoy-destruct() {
|
||||||
sonobuoy logs
|
mkdir -p ${LOGS}
|
||||||
|
sonobuoy logs >${LOGS}/$i-sonobuoy.log 2>&1
|
||||||
sonobuoy delete --wait
|
sonobuoy delete --wait
|
||||||
}
|
}
|
||||||
export -f sonobuoy-destruct
|
export -f sonobuoy-destruct
|
||||||
|
@ -179,6 +167,7 @@ trap cleanup EXIT
|
||||||
|
|
||||||
K3S_PORT=$(timeout --foreground 5s bash -c get-port)
|
K3S_PORT=$(timeout --foreground 5s bash -c get-port)
|
||||||
OUTPUT=$(pwd)/sonobuoy-output/${K3S_PORT}
|
OUTPUT=$(pwd)/sonobuoy-output/${K3S_PORT}
|
||||||
|
LOGS=$(pwd)/logs/$$
|
||||||
E2E="${OUTPUT}/e2e"
|
E2E="${OUTPUT}/e2e"
|
||||||
E2E_LOG="plugins/e2e/results/e2e.log"
|
E2E_LOG="plugins/e2e/results/e2e.log"
|
||||||
RESULTS="${E2E}/${E2E_LOG}"
|
RESULTS="${E2E}/${E2E_LOG}"
|
||||||
|
|
|
@ -3,15 +3,6 @@ set -e -x
|
||||||
|
|
||||||
cd $(dirname $0)/..
|
cd $(dirname $0)/..
|
||||||
|
|
||||||
cleanup() {
|
|
||||||
exit_code=$?
|
|
||||||
set +e
|
|
||||||
wait
|
|
||||||
echo "Finished the tests!"
|
|
||||||
exit ${exit_code}
|
|
||||||
}
|
|
||||||
trap cleanup EXIT
|
|
||||||
|
|
||||||
if [ -z "$K3S_IMAGE" ]; then
|
if [ -z "$K3S_IMAGE" ]; then
|
||||||
source $(dirname $0)/version.sh
|
source $(dirname $0)/version.sh
|
||||||
TAG=${TAG:-${VERSION}${SUFFIX}}
|
TAG=${TAG:-${VERSION}${SUFFIX}}
|
||||||
|
@ -32,7 +23,6 @@ run-sonobuoy() {
|
||||||
pids+=($!)
|
pids+=($!)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
log_output=${OUTPUT}/e2e-STATUS-${ARCH}-parallel.log \
|
log_output=${OUTPUT}/e2e-STATUS-${ARCH}-parallel.log \
|
||||||
run-sonobuoy --e2e-focus='\[Conformance\]' --e2e-skip='\[Serial\]' --e2e-parallel=y
|
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 \
|
log_output=${OUTPUT}/e2e-STATUS-${ARCH}-serial.log \
|
||||||
run-sonobuoy --e2e-focus='\[Serial\].*\[Conformance\]'
|
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
|
for pid in "${pids[@]}"; do
|
||||||
wait $pid || exit $?
|
wait $pid || exit $?
|
||||||
|
|
Loading…
Reference in New Issue