From 68fd0cd2884e8c1f2c00037030f2b796fce018ad Mon Sep 17 00:00:00 2001 From: Michal Nasiadka Date: Mon, 16 Jan 2023 10:19:10 +0000 Subject: [PATCH] CI: improve get_logs.sh Change-Id: I2546d714d1e6a1b648a4c6242ece18a2108b9183 --- tests/get_logs.sh | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/tests/get_logs.sh b/tests/get_logs.sh index 13253d8d7a..ceebc169a8 100644 --- a/tests/get_logs.sh +++ b/tests/get_logs.sh @@ -16,10 +16,10 @@ copy_logs() { exit 1 fi - cp -rnL ${VOLUMES_DIR}/kolla_logs/_data/* ${LOG_DIR}/kolla/ - cp -rnL /etc/kolla/* ${LOG_DIR}/kolla_configs/ + [ -d ${VOLUMES_DIR}/kolla_logs/_data ] && cp -rnL ${VOLUMES_DIR}/kolla_logs/_data/* ${LOG_DIR}/kolla/ + [ -d /etc/kolla ] && cp -rnL /etc/kolla/* ${LOG_DIR}/kolla_configs/ # Don't save the IPA images. - rm ${LOG_DIR}/kolla_configs/config/ironic/ironic-agent.{kernel,initramfs} + rm -f ${LOG_DIR}/kolla_configs/config/ironic/ironic-agent.{kernel,initramfs} mkdir ${LOG_DIR}/system_configs/ cp -rL /etc/{hostname,hosts,host.conf,resolv.conf,nsswitch.conf,systemd} ${LOG_DIR}/system_configs/ # copy docker configs if used @@ -37,10 +37,6 @@ copy_logs() { if [ "$CONTAINER_ENGINE" = "docker" ]; then journalctl --no-pager -u containerd.service > ${LOG_DIR}/system_logs/containerd.log fi - else - if [ "$CONTAINER_ENGINE" = "docker" ]; then - cp /var/log/upstart/docker.log ${LOG_DIR}/system_logs/docker.log - fi fi cp -r /etc/sudoers.d ${LOG_DIR}/system_logs/ @@ -101,21 +97,22 @@ copy_logs() { ps -eo user,pid,ppid,lwp,%cpu,%mem,size,rss,cmd > ${LOG_DIR}/system_logs/ps.txt # container engine related information - (${CONTAINER_ENGINE} info && - ${CONTAINER_ENGINE} images && - ${CONTAINER_ENGINE} ps -a && - ${CONTAINER_ENGINE} network ls && - ${CONTAINER_ENGINE} inspect $(${CONTAINER_ENGINE} ps -aq)) > ${LOG_DIR}/system_logs/${CONTAINER_ENGINE}-info.txt + [ `command -v ${CONTAINER_ENGINE}` ] && + ( ${CONTAINER_ENGINE} info && + ${CONTAINER_ENGINE} images && + ${CONTAINER_ENGINE} ps -a && + ${CONTAINER_ENGINE} network ls && + ${CONTAINER_ENGINE} inspect $(${CONTAINER_ENGINE} ps -aq)) > ${LOG_DIR}/system_logs/${CONTAINER_ENGINE}-info.txt # save dbus services - dbus-send --system --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.ListNames > ${LOG_DIR}/system_logs/dbus-services.txt + [ `command -v dbus-send` ] && dbus-send --system --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.ListNames > ${LOG_DIR}/system_logs/dbus-services.txt # cephadm related logs if [ `command -v cephadm` ]; then mkdir -p ${LOG_DIR}/ceph - sudo cp /etc/ceph/ceph.conf ${LOG_DIR}/ceph - sudo cp /var/run/ceph/*/cluster.yml ${LOG_DIR}/ceph/cluster.yml - sudo cp /var/log/ceph/cephadm.log* ${LOG_DIR}/ceph/ + [ -d /etc/ceph ] && sudo cp /etc/ceph/ceph.conf ${LOG_DIR}/ceph + [ -d /var/run/ceph ] && sudo cp /var/run/ceph/*/cluster.yml ${LOG_DIR}/ceph/cluster.yml + [ -d /var/log/ceph ] && sudo cp /var/log/ceph/cephadm.log* ${LOG_DIR}/ceph/ sudo cephadm shell -- ceph --connect-timeout 5 -s > ${LOG_DIR}/ceph/ceph_s.txt sudo cephadm shell -- ceph --connect-timeout 5 osd tree > ${LOG_DIR}/ceph/ceph_osd_tree.txt fi