Skip to content

Commit 3f41600

Browse files
committed
Fix pod log gathering
Some tar versions return exit code 1 on warnings such as file changed during read, other return exit code 0. With this patch the tar command run used to gather /var/log/pods will only be considered failed if the exit code is 2 or greater.
1 parent 9e6f255 commit 3f41600

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

collection-scripts/gather_sos

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,15 @@ gather_node_sos () {
7373
# To avoid performance penalty we don't look for the real directory name using:
7474
# $(tar --exclude='*/*' -tf "${FILENAME}" | head -n1)
7575
# Instead we use a fake podlogs top directory
76+
# - Ignore warning exit code (1) from tar, and only consider it a failure on error code (2)
7677
oc debug "node/$node" -- chroot /host bash \
7778
-c "echo 'TOOLBOX_NAME=toolbox-osp' > /root/.toolboxrc ; \
7879
rm -rf \"${TMPDIR}\" && \
7980
mkdir -p \"${TMPDIR}\" && \
8081
sudo podman rm --force toolbox-osp; \
8182
sudo --preserve-env podman pull --authfile /var/lib/kubelet/config.json registry.redhat.io/rhel9/support-tools && \
8283
toolbox sos report --batch $SOS_LIMIT --tmp-dir=\"${TMPDIR}\" && \
83-
tar --warning=no-file-changed -cJf \"${TMPDIR}/podlogs.tar.xz\" --transform 's,^,podlogs/,' /var/log/pods"
84+
tar --warning=no-file-changed -cJf \"${TMPDIR}/podlogs.tar.xz\" --transform 's,^,podlogs/,' /var/log/pods; [ \$? -lt 2 ]"
8485

8586
# shellcheck disable=SC2181
8687
if [ $? -ne 0 ]; then

0 commit comments

Comments
 (0)