Skip to content

Commit c65cbc3

Browse files
chrischdik8s-infra-cherrypick-robot
authored andcommitted
e2e: also collect pod logs
1 parent ab6e4bd commit c65cbc3

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

hack/e2e.sh

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ 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+
tar -xzf "${tarball}" -C "${tarball}-unpacked"
69+
rm "${tarball}"
70+
done
6471
# Delete non-text files from artifacts directory to not leak files accidentially
6572
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
6673
do
@@ -83,6 +90,13 @@ on_exit() {
8390
sed -i "s/${VSPHERE_PASSWORD_B64}/REDACTED/g" "${file}"
8491
done || true
8592
fi
93+
# re-packing pod-logs.tar.gz-unpacked
94+
find "${ARTIFACTS}" -type d -name pod-logs.tar.gz-unpacked | while IFS= read -r tarballDirectory; do
95+
tarball="${tarballDirectory%-unpacked}"
96+
echo "Packing ${tarballDirectory} to ${tarball} after secrets replacement"
97+
tar -czf "${tarball}" -C . "${tarballDirectory}"
98+
rm -r "${tarballDirectory}"
99+
done
86100
# Move all artifacts to the original artifacts location.
87101
mv "${ARTIFACTS}"/* "${ORIGINAL_ARTIFACTS}/"
88102
fi
@@ -104,7 +118,7 @@ export VSPHERE_USERNAME="${GOVC_USERNAME:-}"
104118
export VSPHERE_PASSWORD="${GOVC_PASSWORD:-}"
105119
export E2E_CONF_FILE="${REPO_ROOT}/test/e2e/config/vsphere.yaml"
106120
export E2E_CONF_OVERRIDE_FILE=""
107-
export E2E_VM_OPERATOR_VERSION="${VM_OPERATOR_VERSION:-v1.8.6-0-gde75746a}"
121+
export E2E_VM_OPERATOR_VERSION="${VM_OPERATOR_VERSION:-v1.8.6-0-gde75746a-65e87004}"
108122
export DOCKER_IMAGE_TAR="/tmp/images/image.tar"
109123
export GC_KIND="false"
110124

test/framework/log/collector.go

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

0 commit comments

Comments
 (0)