Skip to content

Commit 55ad4de

Browse files
collect log from previous container instance
Signed-off-by: changzhen <[email protected]>
1 parent a892fef commit 55ad4de

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

hack/run-e2e.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,18 @@ check_component_restart() {
122122
if [ "$restart_count" -gt 0 ]; then
123123
echo "ERROR: ${component_name} pod $pod_name has restarted $restart_count times."
124124
echo "This indicates OOM or panic occurred and needs to be investigated."
125+
126+
# Collect logs from the previous container instance
127+
echo "Collecting logs from previous container instance for ${component_name} pod $pod_name..."
128+
local log_file="$ARTIFACTS_PATH/${component_name}-${pod_name}-previous-logs.log"
129+
kubectl --context="${KARMADA_HOST_CLUSTER_NAME}" logs -p "$pod_name" -n karmada-system > "$log_file" 2>&1
130+
131+
if [ $? -eq 0 ]; then
132+
echo "Previous container logs saved to: $log_file"
133+
else
134+
echo "Warning: Failed to collect previous container logs for pod $pod_name"
135+
fi
136+
125137
return 1 # Return failure to stop checking
126138
else
127139
echo "${component_name} pod $pod_name: no restarts"

0 commit comments

Comments
 (0)