Skip to content

Commit 5502581

Browse files
committed
hack/collectlogs: make ORC pod log collection more robust
Resolve the pod name explicitly instead of relying on a label selector, capture stderr from kubectl logs into the log file, and detect empty log files with a --previous fallback. Closes #839
1 parent 95c906a commit 5502581

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

hack/collectlogs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,14 @@ done
2727
cp ./devstack/local.conf "$DEVSTACK_LOG_DIR"
2828

2929
kubectl describe pods -n orc-system > "$LOG_DIR/orc-pod.txt"
30-
kubectl logs -n orc-system -l control-plane=controller-manager --tail=-1 > "$LOG_DIR/orc-pod.log"
30+
31+
ORC_POD=$(kubectl get pods -n orc-system -l control-plane=controller-manager -o jsonpath='{.items[0].metadata.name}')
32+
kubectl logs -n orc-system "$ORC_POD" --tail=-1 > "$LOG_DIR/orc-pod.log" 2>&1
33+
34+
if [ ! -s "$LOG_DIR/orc-pod.log" ]; then
35+
echo "WARNING: orc-pod.log is empty, trying --previous" >&2
36+
kubectl logs -n orc-system "$ORC_POD" --previous > "$LOG_DIR/orc-pod-previous.log" 2>&1 || true
37+
fi
3138

3239
kubectl get -n orc-system all -o yaml > "$LOG_DIR/orc-resources.yaml"
3340

0 commit comments

Comments
 (0)