Skip to content

Commit 558ae4d

Browse files
feat: adding log collection in workflow file
1 parent 5af3349 commit 558ae4d

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

.github/workflows/e2e.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,54 @@ jobs:
9191
KINDEST_IMAGE_TAG: ${{ inputs.kubernetes-version }}
9292
E2E_KUBERNETES_VERSION: ${{ inputs.kubernetes-version }}
9393

94+
- name: Collect bootstrap cluster pod logs on failure
95+
if: failure()
96+
run: |
97+
echo "Collecting pod logs from bootstrap cluster..."
98+
mkdir -p bootstrap-pod-logs
99+
100+
# Get kubeconfig path for bootstrap cluster
101+
BOOTSTRAP_KUBECONFIG=$(find _artifacts/clusters/bootstrap -name kubeconfig 2>/dev/null | head -n 1)
102+
103+
if [[ -n "$BOOTSTRAP_KUBECONFIG" ]]; then
104+
export KUBECONFIG="$BOOTSTRAP_KUBECONFIG"
105+
106+
# Get all pods overview
107+
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
108+
109+
# Get CAREN controller logs (main focus)
110+
echo "Collecting CAREN controller logs..."
111+
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
112+
113+
# Get all CAPI provider logs
114+
echo "Collecting CAPI provider logs..."
115+
for ns in capi-system capi-kubeadm-bootstrap-system capi-kubeadm-control-plane-system capd-system capn-system capa-system caaph-system; do
116+
if kubectl get namespace "$ns" >/dev/null 2>&1; then
117+
mkdir -p "bootstrap-pod-logs/$ns"
118+
kubectl get pods -n "$ns" -o wide > "bootstrap-pod-logs/$ns/pods.txt" 2>&1 || true
119+
for pod in $(kubectl get pods -n "$ns" -o name 2>/dev/null); do
120+
pod_name=$(basename "$pod")
121+
kubectl logs -n "$ns" "$pod_name" --all-containers=true --tail=500 > "bootstrap-pod-logs/$ns/${pod_name}.log" 2>&1 || true
122+
done
123+
fi
124+
done
125+
126+
# Get HelmReleaseProxy and HelmChartProxy resources
127+
echo "Collecting Helm addon resources..."
128+
kubectl get helmreleaseproxies -A -o yaml > bootstrap-pod-logs/helmreleaseproxies.yaml 2>&1 || true
129+
kubectl get helmchartproxies -A -o yaml > bootstrap-pod-logs/helmchartproxies.yaml 2>&1 || true
130+
else
131+
echo "Bootstrap kubeconfig not found" > bootstrap-pod-logs/error.txt
132+
fi
133+
134+
- name: Upload bootstrap pod logs
135+
if: failure()
136+
uses: actions/upload-artifact@v4
137+
with:
138+
name: bootstrap-pod-logs-${{ inputs.provider }}-${{ inputs.kubernetes-version }}
139+
path: bootstrap-pod-logs/
140+
if-no-files-found: warn
141+
94142
- if: success() || failure() # always run even if the previous step fails
95143
name: Publish e2e test report
96144
uses: mikepenz/action-junit-report@v5

0 commit comments

Comments
 (0)