Refactor "get_instance_info" gathering

This change re-factors the "get_instance_info" function so that it's
logging everything to a file instead of stdout. This will help
folks with debugging the gate. The function was logging most of
important data to stdout which is only trapped by the main
playbook run and caused someone to load the entire run output
to get useful information about the environment.

In addition to logging everything to a file the custom fact gathering
commands we were running have been removed in-favor of simply running
the ansible setup module which will provide a lot more data in a
format that is far easier to consume.

Change-Id: Icd5d600f58e59c541bca41a21642c2d270315aaf
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
This commit is contained in:
Kevin Carter 2016-07-26 23:02:09 -05:00 committed by Jesse Pretorius (odyssey4me)
parent d3e54871e6
commit 233eb80c2d

View File

@ -126,7 +126,6 @@ function exit_success {
function exit_fail { function exit_fail {
set +x set +x
log_instance_info log_instance_info
cat ${INFO_FILENAME}
info_block "Error Info - $@" info_block "Error Info - $@"
[[ "${OSA_GATE_JOB:-false}" = true ]] && gate_job_exit_tasks [[ "${OSA_GATE_JOB:-false}" = true ]] && gate_job_exit_tasks
exit_state 1 exit_state 1
@ -153,71 +152,54 @@ function log_instance_info {
if [ ! -d "/openstack/log/instance-info" ];then if [ ! -d "/openstack/log/instance-info" ];then
mkdir -p "/openstack/log/instance-info" mkdir -p "/openstack/log/instance-info"
fi fi
export INFO_FILENAME="/openstack/log/instance-info/host_info_$(date +%s).log" get_instance_info
get_instance_info &> ${INFO_FILENAME}
set -x set -x
} }
function get_repos_info { function get_repos_info {
for i in /etc/apt/sources.list /etc/apt/sources.list.d/*; do for i in /etc/apt/sources.list /etc/apt/sources.list.d/* /etc/yum.conf /etc/yum.repos.d/*; do
echo -e "\n$i" if [ -f "${i}" ]; then
cat $i echo -e "\n$i"
cat $i
fi
done done
} }
# Get instance info # Get instance info
function get_instance_info { function get_instance_info {
set +x TS="$(date +"%H-%M-%S")"
info_block 'Current User' (cat /etc/resolv.conf && \
whoami which systemd-resolve && \
info_block 'Available Memory' systemd-resolve --statistics && \
free -mt || true cat /etc/systemd/resolved.conf) > \
info_block 'Available Disk Space' "/openstack/log/instance-info/host_dns_info_${TS}.log" || true
df -h || true tracepath "8.8.8.8" -m 5 > \
info_block 'Mounted Devices' "/openstack/log/instance-info/host_tracepath_info_${TS}.log" || true
mount || true tracepath6 "2001:4860:4860::8888" -m 5 >> \
info_block 'Block Devices' "/openstack/log/instance-info/host_tracepath_info_${TS}.log" || true
lsblk -i || true lxc-ls --fancy > \
info_block 'Block Devices Information' "/openstack/log/instance-info/host_lxc_container_info_${TS}.log" || true
blkid || true lxc-checkconfig > \
info_block 'Block Device Partitions' "/openstack/log/instance-info/host_lxc_config_info_${TS}.log" || true
for i in /dev/xv* /dev/sd* /dev/vd*; do (iptables -vnL && iptables -t nat -vnL && iptables -t mangle -vnL) > \
if [ -b "$i" ];then "/openstack/log/instance-info/host_firewall_info_${TS}.log" || true
parted --script $i print || true ANSIBLE_HOST_KEY_CHECKING=False \
fi ansible -i "localhost," localhost -m setup > \
done "/openstack/log/instance-info/host_system_info_${TS}.log" || true
info_block 'PV Information' get_repos_info > \
pvs || true "/openstack/log/instance-info/host_repo_info_${TS}.log" || true
info_block 'VG Information'
vgs || true determine_distro
info_block 'LV Information' case ${DISTRO_ID} in
lvs || true centos|rhel|fedora)
info_block 'CPU Information' rpm -qa > \
which lscpu && lscpu || true "/openstack/log/instance-info/host_packages_info_${TS}.log" || true
info_block 'Kernel Information' ;;
uname -a || true ubuntu|debian)
info_block 'Container Information' dpkg-query --list > \
which lxc-ls && lxc-ls --fancy || true "/openstack/log/instance-info/host_packages_info_${TS}.log" || true
info_block 'Firewall Information' ;;
iptables -vnL || true esac
iptables -t nat -vnL || true
iptables -t mangle -vnL || true
info_block 'Network Devices'
ip a || true
info_block 'Network Routes'
ip r || true
info_block 'DNS Configuration'
cat /etc/resolv.conf
info_block 'Trace Path from google'
tracepath 8.8.8.8 -m 5 || true
info_block 'XEN Server Information'
if (which xenstore-read);then
xenstore-read vm-data/provider_data/provider || echo "\nxenstore Read Failed - Skipping\n"
else
echo -e "\nNo xenstore Information\n"
fi
get_repos_info &> /openstack/log/instance-info/host_repo_info_$(date +%s).log || true
dpkg-query --list &> /openstack/log/instance-info/host_packages_info_$(date +%s).log
} }
function print_report { function print_report {
@ -289,7 +271,7 @@ fi
## Exports ------------------------------------------------------------------- ## Exports -------------------------------------------------------------------
# Export known paths # Export known paths
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${PATH}"
# Export the home directory just in case it's not set # Export the home directory just in case it's not set
export HOME="/root" export HOME="/root"