7fb32dd599
The scripts/collect-test-info.sh script is executed with '-u' which means that unset variables will trigger an error like the following one: scripts/collect-test-info.sh: line 16: TEST_VM_NODE_NAMES: unbound variable We handle this case by simply setting an alternative value when the variable is set in order to treat the unset variable gracefully. Change-Id: Ic4b450fe8654568e30eacb00aeff128d675ed616
48 lines
2.0 KiB
Bash
Executable File
48 lines
2.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Note(TheJulia): We should proceed with attempting to collect information
|
|
# even if a command fails, and as such set -e should not be present.
|
|
set -ux
|
|
set -o pipefail
|
|
|
|
# Note(TheJulia): If there is a workspace variable, we want to utilize that as
|
|
# the preference of where to put logs
|
|
SCRIPT_HOME="$(cd "$(dirname "$0")" && pwd)"
|
|
LOG_LOCATION="${WORKSPACE:-${SCRIPT_HOME}/..}/logs"
|
|
|
|
echo "Making logs directory and collecting logs."
|
|
[ -d ${LOG_LOCATION} ] || mkdir -p ${LOG_LOCATION}
|
|
|
|
if [ -z "${TEST_VM_NODE_NAMES+x}" ]; then
|
|
sudo cp /var/log/libvirt/baremetal_logs/testvm[[:digit:]]_console.log ${LOG_LOCATION}
|
|
sudo chown $USER ${LOG_LOCATION}/testvm[[:digit:]]_console.log
|
|
sudo chmod o+r ${LOG_LOCATION}/testvm[[:digit:]]_console.log
|
|
else
|
|
for TEST_VM_NODE_NAME in ${TEST_VM_NODE_NAMES}; do
|
|
sudo cp /var/log/libvirt/baremetal_logs/${TEST_VM_NODE_NAME}_console.log ${LOG_LOCATION}
|
|
sudo chown $USER ${LOG_LOCATION}/${TEST_VM_NODE_NAME}_console.log
|
|
sudo chmod o+r ${LOG_LOCATION}/${TEST_VM_NODE_NAME}_console.log
|
|
done
|
|
fi
|
|
dmesg &> ${LOG_LOCATION}/dmesg.log
|
|
# NOTE(TheJulia): Netstat exits with error code 5 when --version is used.
|
|
sudo netstat -apn &> ${LOG_LOCATION}/netstat.log
|
|
if $(iptables --version &>/dev/null); then
|
|
sudo iptables -L -n -v &> ${LOG_LOCATION}/iptables.log
|
|
fi
|
|
if $(ip link &>/dev/null); then
|
|
ip -s link &> ${LOG_LOCATION}/interface_counters.log
|
|
fi
|
|
if $(journalctl --version &>/dev/null); then
|
|
sudo journalctl -u ironic-api &> ${LOG_LOCATION}/ironic-api.log
|
|
sudo journalctl -u ironic-conductor &> ${LOG_LOCATION}/ironic-conductor.log
|
|
else
|
|
sudo cp /var/log/upstart/ironic-api.log ${LOG_LOCATION}/
|
|
sudo cp /var/log/upstart/ironic-conductor.log ${LOG_LOCATION}/
|
|
fi
|
|
sudo chown $USER ${LOG_LOCATION}/ironic-api.log
|
|
sudo chown $USER ${LOG_LOCATION}/ironic-conductor.log
|
|
# In CI scenarios, we want other users to be able to read the logs.
|
|
sudo chmod o+r ${LOG_LOCATION}/ironic-api.log
|
|
sudo chmod o+r ${LOG_LOCATION}/ironic-conductor.log
|