diff --git a/hack/collector-harvester b/hack/collector-harvester index afec64c10..ee7bd17c3 100755 --- a/hack/collector-harvester +++ b/hack/collector-harvester @@ -1,5 +1,6 @@ #!/bin/bash -ux +source /tmp/common HOST_PATH=$1 BUNDLE_DIR=$2 @@ -99,18 +100,18 @@ mv $HOST_PATH/var/log/scc_supportconfig_$SUPPORT_BUNDLE_NODE_NAME.txz ./scc mkdir -p logs cd logs -chroot $HOST_PATH /usr/bin/journalctl -k > kernel.log +chroot $HOST_PATH $JOURNALCTL -k > kernel.log # also collect logs of previous two boots for ((i=1; i<=2; i++)); do log_name="kernel.log.$i" - chroot $HOST_PATH /usr/bin/journalctl -k -b $((-i)) > $log_name + chroot $HOST_PATH $JOURNALCTL -k -b $((-i)) > $log_name [ ! -s $log_name ] && rm -f $log_name done units=(rke2-server rke2-agent rancherd rancher-system-agent wicked iscsid) for unit in ${units[@]}; do - chroot $HOST_PATH /usr/bin/journalctl -b all -u $unit | tail -c 10m > $unit.log + chroot $HOST_PATH $JOURNALCTL -b all -u $unit | tail -c 10m > $unit.log done cp ${HOST_PATH}/var/lib/rancher/rke2/agent/logs/kubelet.log . diff --git a/hack/collector-longhorn b/hack/collector-longhorn index daf0533e1..0fc55d99f 100644 --- a/hack/collector-longhorn +++ b/hack/collector-longhorn @@ -1,5 +1,6 @@ #!/bin/bash -ux +source /tmp/common HOST_PATH=$1 BUNDLE_DIR=$2 @@ -33,11 +34,11 @@ function collect_syslog(){ function collect_kubelet_log(){ # On Linux nodes that use systemd, the kubelet and container runtime write to journald by default. # ref. https://kubernetes.io/docs/concepts/cluster-administration/logging/#log-location-node - chroot ${HOST_PATH} /usr/bin/journalctl -r -u kubelet > kubelet.log + chroot ${HOST_PATH} $JOURNALCTL -r -u kubelet > kubelet.log # For K3s cluster - chroot ${HOST_PATH} /usr/bin/journalctl -r -u k3s.service > k3s-service.log - chroot ${HOST_PATH} /usr/bin/journalctl -r -u k3s-agent.service > k3s-agent-service.log + chroot ${HOST_PATH} $JOURNALCTL -r -u k3s.service > k3s-service.log + chroot ${HOST_PATH} $JOURNALCTL -r -u k3s-agent.service > k3s-agent-service.log if [ -f ${RKE2_KUBELET_LOG_PATH} ]; then cp ${RKE2_KUBELET_LOG_PATH} . diff --git a/hack/common b/hack/common new file mode 100644 index 000000000..29cf57a59 --- /dev/null +++ b/hack/common @@ -0,0 +1,2 @@ + +JOURNALCTL="/usr/bin/journalctl -o short-precise" diff --git a/package/Dockerfile b/package/Dockerfile index d9c9035a4..68e75703f 100644 --- a/package/Dockerfile +++ b/package/Dockerfile @@ -35,4 +35,6 @@ RUN chmod +x /usr/bin/support-bundle-kit ADD hack/collector-* /usr/bin/ RUN chmod +x /usr/bin/collector-* +ADD hack/common /tmp/ + ENTRYPOINT ["entrypoint.sh"]