Skip to content

Commit 8f0502f

Browse files
committed
trial-4: retireve runc logs
Signed-off-by: Ansuman Sahoo <anshumansahoo500@gmail.com>
1 parent c583e81 commit 8f0502f

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

hack/test-templates.sh

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -399,16 +399,14 @@ if [[ -n ${CHECKS["container-engine"]} ]]; then
399399

400400
if ! timeout 3m bash -euxc "until curl -f --retry 15 --retry-connrefused http://127.0.0.1:8080; do sleep 3; done"; then
401401
INFO "=== DEBUG: port forwarding failed (#5030) ==="
402-
# Container state (full inspect, first 80 lines)
402+
# Container state (inspect, first 80 lines)
403403
limactl shell "$NAME" $sudo $CONTAINER_ENGINE inspect nginx 2>&1 | head -80 || true
404404
# Container logs (stdout+stderr)
405405
limactl shell "$NAME" $sudo $CONTAINER_ENGINE logs nginx 2>&1 || true
406-
# Run nginx in foreground to see actual startup error
407-
limactl shell "$NAME" $sudo $CONTAINER_ENGINE run --rm --name nginx-debug ${nginx_image} sh -c 'nginx -g "daemon off;" 2>&1 & PID=$!; sleep 5; kill $PID 2>/dev/null; wait $PID 2>/dev/null' || true
408-
# What's listening inside the rootlesskit child namespace
409-
limactl shell "$NAME" bash -c 'CHILD=$(cat /run/user/$(id -u)/containerd-rootless/child_pid 2>/dev/null); [ -n "$CHILD" ] && sudo nsenter -t "$CHILD" -n ss -tlnp || echo "no child_pid"' || true
410-
# Rootlesskit network driver confirmation
411-
limactl shell "$NAME" bash -c 'pgrep -a rootlesskit | head -1' || true
406+
# OCI runtime (runc) log -- contains the REAL reason container failed to start
407+
limactl shell "$NAME" bash -c 'CID=$('"$sudo"' '"$CONTAINER_ENGINE"' inspect nginx --format "{{.Id}}" 2>/dev/null); for f in ~/.local/share/containerd/io.containerd.runtime.v2.task/default/$CID/log.json /home/*/.local/share/containerd/io.containerd.runtime.v2.task/default/$CID/log.json; do [ -f "$f" ] && echo "=== $f ===" && cat "$f"; done' || true
408+
# Containerd journal as the rootless user
409+
limactl shell "$NAME" sudo bash -c 'U=$(logname); machinectl shell --uid="$U" .host /bin/bash -c "journalctl --user -u containerd --no-pager -n 100" 2>/dev/null || sudo -u "$U" XDG_RUNTIME_DIR=/run/user/$(id -u "$U") journalctl --user -u containerd --no-pager -n 100' || true
412410
INFO "=== END DEBUG ==="
413411
ERROR "Port forwarding to nginx container on 127.0.0.1:8080 failed"
414412
exit 1

0 commit comments

Comments
 (0)