Skip to content

Commit 9219d2f

Browse files
authored
🌱 e2e: also collect pod logs (#3490)
* e2e: also collect pod logs * fixup e2e.sh * fixup tarball re-creation * e2e.sh: ensure on_exit to not fail due to broken or empty tarballs
1 parent b90aa22 commit 9219d2f

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

‎hack/e2e.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ on_exit() {
6161

6262
# Cleanup VSPHERE_PASSWORD from temporary artifacts directory.
6363
if [[ "${ORIGINAL_ARTIFACTS}" != "" ]]; then
64+
# unpack pod-logs.tar.gz files to replace secrets in them
65+
find "${ARTIFACTS}" -type f -name pod-logs.tar.gz | while IFS= read -r tarball; do
66+
echo "Unpacking ${tarball} for secrets replacement"
67+
mkdir -p "${tarball}-unpacked"
68+
# on_exit should not fail due to broken tarballs
69+
tar -xzf "${tarball}" -C "${tarball}-unpacked" || true
70+
rm "${tarball}"
71+
done
6472
# Delete non-text files from artifacts directory to not leak files accidentially
6573
find "${ARTIFACTS}" -type f -exec file --mime-type {} \; | grep -v -E -e "text/plain|text/xml|application/json|inode/x-empty" | while IFS= read -r line
6674
do
@@ -83,6 +91,13 @@ on_exit() {
8391
sed -i "s/${VSPHERE_PASSWORD_B64}/REDACTED/g" "${file}"
8492
done || true
8593
fi
94+
# re-packing pod-logs.tar.gz-unpacked
95+
find "${ARTIFACTS}" -type d -name pod-logs.tar.gz-unpacked | while IFS= read -r tarballDirectory; do
96+
tarball="${tarballDirectory%-unpacked}"
97+
echo "Packing ${tarballDirectory} to ${tarball} after secrets replacement"
98+
tar -czf "${tarball}" -C "${tarballDirectory}" .
99+
rm -r "${tarballDirectory}"
100+
done
86101
# Move all artifacts to the original artifacts location.
87102
mv "${ARTIFACTS}"/* "${ORIGINAL_ARTIFACTS}/"
88103
fi

‎test/framework/log/collector.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ func (c *MachineLogCollector) CollectMachineLog(ctx context.Context, ctrlClient
9797
"sudo", "cat", "/var/log/cloud-init-output.log"),
9898
captureLogs("kubeadm-service.log",
9999
"sudo", "cat", "/var/log/kubeadm-service.log"),
100+
captureLogs("pod-logs.tar.gz",
101+
"sudo", "tar", "-czf", "-", "-C", "/var/log", "pods"),
100102
)
101103
}
102104

0 commit comments

Comments
 (0)