Skip to content

Commit a18aadc

Browse files
feat: collect logs on failure
1 parent 8807e64 commit a18aadc

File tree

1 file changed

+52
-8
lines changed

1 file changed

+52
-8
lines changed

.github/workflows/e2e.yml

Lines changed: 52 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,26 +94,58 @@ jobs:
9494
- name: Collect bootstrap cluster pod logs on failure
9595
if: failure()
9696
run: |
97-
echo "Collecting pod logs from bootstrap cluster..."
97+
set -x # Enable debug mode to see all commands
98+
echo "===== Starting log collection ====="
9899
mkdir -p bootstrap-pod-logs
99100
100-
# Get kubeconfig path for bootstrap cluster
101-
BOOTSTRAP_KUBECONFIG=$(find _artifacts/clusters/bootstrap -name kubeconfig 2>/dev/null | head -n 1)
101+
# Check if Kind cluster exists first
102+
echo "Checking for Kind clusters..."
103+
devbox run -- kind get clusters > bootstrap-pod-logs/kind-clusters.txt 2>&1 || true
104+
cat bootstrap-pod-logs/kind-clusters.txt
102105
103-
if [[ -n "$BOOTSTRAP_KUBECONFIG" ]]; then
104-
export KUBECONFIG="$BOOTSTRAP_KUBECONFIG"
106+
# Get kubeconfig from Kind cluster (name: caren-e2e from test/e2e/config/caren.yaml)
107+
echo "Getting kubeconfig from Kind cluster 'caren-e2e'..."
108+
if devbox run -- kind get kubeconfig --name caren-e2e > bootstrap-pod-logs/kubeconfig.yaml 2>&1; then
109+
echo "✓ Successfully retrieved kubeconfig from Kind cluster"
110+
111+
# Use absolute path for KUBECONFIG
112+
export KUBECONFIG="${PWD}/bootstrap-pod-logs/kubeconfig.yaml"
113+
echo "✓ KUBECONFIG set to: $KUBECONFIG"
114+
115+
# Verify kubectl works
116+
echo "Verifying kubectl connectivity..."
117+
if kubectl cluster-info &> bootstrap-pod-logs/cluster-info.txt; then
118+
echo "✓ kubectl can connect to cluster"
119+
cat bootstrap-pod-logs/cluster-info.txt
120+
else
121+
echo "✗ kubectl cannot connect to cluster"
122+
cat bootstrap-pod-logs/cluster-info.txt
123+
exit 0 # Exit gracefully, don't fail the workflow
124+
fi
105125
106126
# Get all pods overview
127+
echo "Getting all pods..."
107128
kubectl get pods -A -o wide > bootstrap-pod-logs/all-pods.txt 2>&1 || echo "Failed to get pods" > bootstrap-pod-logs/all-pods.txt
129+
echo "✓ Saved all-pods.txt"
130+
131+
# Get all namespaces
132+
kubectl get namespaces > bootstrap-pod-logs/namespaces.txt 2>&1 || true
133+
echo "✓ Saved namespaces.txt"
108134
109-
# Get CAREN controller logs (main focus)
135+
# Get CAREN controller logs (main focus - this is what you need for konnector-agent debugging)
110136
echo "Collecting CAREN controller logs..."
111137
kubectl logs -n caren-system -l app.kubernetes.io/name=cluster-api-runtime-extensions-nutanix --all-containers=true --tail=1000 > bootstrap-pod-logs/caren-controller.log 2>&1 || echo "Failed to get CAREN logs" > bootstrap-pod-logs/caren-controller.log
138+
echo "✓ Saved caren-controller.log ($(wc -l < bootstrap-pod-logs/caren-controller.log) lines)"
139+
140+
# Get CAREN controller pod descriptions
141+
kubectl describe pods -n caren-system -l app.kubernetes.io/name=cluster-api-runtime-extensions-nutanix > bootstrap-pod-logs/caren-pods-describe.txt 2>&1 || true
142+
echo "✓ Saved caren-pods-describe.txt"
112143
113144
# Get all CAPI provider logs
114145
echo "Collecting CAPI provider logs..."
115146
for ns in capi-system capi-kubeadm-bootstrap-system capi-kubeadm-control-plane-system capd-system capn-system capa-system caaph-system; do
116147
if kubectl get namespace "$ns" >/dev/null 2>&1; then
148+
echo " ✓ Collecting logs from namespace: $ns"
117149
mkdir -p "bootstrap-pod-logs/$ns"
118150
kubectl get pods -n "$ns" -o wide > "bootstrap-pod-logs/$ns/pods.txt" 2>&1 || true
119151
for pod in $(kubectl get pods -n "$ns" -o name 2>/dev/null); do
@@ -123,12 +155,24 @@ jobs:
123155
fi
124156
done
125157
126-
# Get HelmReleaseProxy and HelmChartProxy resources
158+
# Get HelmReleaseProxy and HelmChartProxy resources (critical for konnector-agent debugging)
127159
echo "Collecting Helm addon resources..."
128160
kubectl get helmreleaseproxies -A -o yaml > bootstrap-pod-logs/helmreleaseproxies.yaml 2>&1 || true
129161
kubectl get helmchartproxies -A -o yaml > bootstrap-pod-logs/helmchartproxies.yaml 2>&1 || true
162+
echo "✓ Saved Helm resources"
163+
164+
# Get all events (helpful for debugging)
165+
echo "Collecting cluster events..."
166+
kubectl get events -A --sort-by='.lastTimestamp' > bootstrap-pod-logs/events.txt 2>&1 || true
167+
echo "✓ Saved events.txt"
168+
169+
echo "===== ✓ Log collection completed successfully ====="
170+
ls -lh bootstrap-pod-logs/
130171
else
131-
echo "Bootstrap kubeconfig not found" > bootstrap-pod-logs/error.txt
172+
echo "===== ✗ Failed to get kubeconfig ====="
173+
cat bootstrap-pod-logs/kubeconfig.yaml || echo "No kubeconfig file"
174+
echo "Checking Docker containers..."
175+
docker ps -a > bootstrap-pod-logs/docker-ps.txt 2>&1 || true
132176
fi
133177
134178
- name: Upload bootstrap pod logs

0 commit comments

Comments
 (0)