Skip to content

🌱 e2e: also collect pod logs #3490

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions hack/e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ on_exit() {

# Cleanup VSPHERE_PASSWORD from temporary artifacts directory.
if [[ "${ORIGINAL_ARTIFACTS}" != "" ]]; then
# unpack pod-logs.tar.gz files to replace secrets in them
Copy link
Member

@sbueringer sbueringer Jun 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this results in a very deep folder hierarchy. In the interest of future us, can we reduce that a bit?

I get this after extract: ./tmp 2/tmp.BAZS1S16eR/clusters/quick-start-l3rsho/machines/quick-start-l3rsho-cp-5x2qt-wfsf5/pod-logs.tar.gz-unpacked/pods/kube-system_etcd-quick-start-l3-wfsf5_6501f15974bbf5a29b9e36b04db38957/etcd.

Ideally kube-system would be top-level in this archive (but just getting rid of *-unpacked and above would be fine as well)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh 🤔 good one. Let me check how this came. I did not expect that either.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be good now.

Its now pods/kube-system_etcd-quick-start-l3-wfsf5_6501f15974bbf5a29b9e36b04db38957/etcd

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I broke it somewhere?!)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect

find "${ARTIFACTS}" -type f -name pod-logs.tar.gz | while IFS= read -r tarball; do
echo "Unpacking ${tarball} for secrets replacement"
mkdir -p "${tarball}-unpacked"
# on_exit should not fail due to broken tarballs
tar -xzf "${tarball}" -C "${tarball}-unpacked" || true
rm "${tarball}"
done
# Delete non-text files from artifacts directory to not leak files accidentially
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
do
Expand All @@ -83,6 +91,13 @@ on_exit() {
sed -i "s/${VSPHERE_PASSWORD_B64}/REDACTED/g" "${file}"
done || true
fi
# re-packing pod-logs.tar.gz-unpacked
find "${ARTIFACTS}" -type d -name pod-logs.tar.gz-unpacked | while IFS= read -r tarballDirectory; do
tarball="${tarballDirectory%-unpacked}"
echo "Packing ${tarballDirectory} to ${tarball} after secrets replacement"
tar -czf "${tarball}" -C "${tarballDirectory}" .
rm -r "${tarballDirectory}"
done
# Move all artifacts to the original artifacts location.
mv "${ARTIFACTS}"/* "${ORIGINAL_ARTIFACTS}/"
fi
Expand Down
2 changes: 2 additions & 0 deletions test/framework/log/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ func (c *MachineLogCollector) CollectMachineLog(ctx context.Context, ctrlClient
"sudo", "cat", "/var/log/cloud-init-output.log"),
captureLogs("kubeadm-service.log",
"sudo", "cat", "/var/log/kubeadm-service.log"),
captureLogs("pod-logs.tar.gz",
"sudo", "tar", "-czf", "-", "-C", "/var/log", "pods"),
)
}

Expand Down