Skip to content

Commit af21714

Browse files
committed
trial-3: logs for nginx container crash failure
Signed-off-by: Ansuman Sahoo <anshumansahoo500@gmail.com>
1 parent 6376713 commit af21714

1 file changed

Lines changed: 12 additions & 13 deletions

File tree

hack/test-templates.sh

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -399,19 +399,18 @@ if [[ -n ${CHECKS["container-engine"]} ]]; then
399399
limactl shell "$NAME" $sudo $CONTAINER_ENGINE pull --quiet ${nginx_image}
400400
limactl shell "$NAME" $sudo $CONTAINER_ENGINE run -d --name nginx -p 127.0.0.1:8080:80 ${nginx_image}
401401

402-
if ! timeout 3m bash -euxc "until curl -f --retry 30 --retry-connrefused http://127.0.0.1:8080; do sleep 3; done"; then
403-
INFO "=== DEBUG: port forwarding failed ==="
404-
limactl shell "$NAME" $sudo $CONTAINER_ENGINE logs nginx || true
405-
limactl shell "$NAME" $sudo $CONTAINER_ENGINE inspect nginx | grep -iE '"Status"|"Running"|"ExitCode"|"Error"|IPAddress' || true
406-
limactl shell "$NAME" bash -c 'echo "slirp4netns binary: $(which slirp4netns 2>/dev/null || echo NOT_FOUND)"' || true
407-
limactl shell "$NAME" bash -c 'cat /run/user/$(id -u)/containerd-rootless/child_pid 2>/dev/null' || true
408-
limactl shell "$NAME" sudo bash -c 'CHILD=$(cat /run/user/$(id -u $(logname))/containerd-rootless/child_pid 2>/dev/null) && [ -n "$CHILD" ] && echo "nsenter curl 127.0.0.1:80:" && nsenter -t "$CHILD" -n curl -sf --max-time 5 http://127.0.0.1:80 || echo "FAILED"' || true
409-
limactl shell "$NAME" sudo bash -c 'CHILD=$(cat /run/user/$(id -u $(logname))/containerd-rootless/child_pid 2>/dev/null) && [ -n "$CHILD" ] && nsenter -t "$CHILD" -n ss -tlnp' || true
410-
limactl shell "$NAME" bash -c 'echo "shell netns: $(readlink /proc/self/ns/net)"; CHILD=$(cat /run/user/$(id -u)/containerd-rootless/child_pid 2>/dev/null); [ -n "$CHILD" ] && echo "child($CHILD) netns: $(readlink /proc/$CHILD/ns/net)"; for p in $(pgrep slirp4netns); do echo "slirp4netns($p) netns: $(readlink /proc/$p/ns/net)"; done' || true
411-
limactl shell "$NAME" bash -c 'if command -v rootlessctl >/dev/null; then rootlessctl --socket /run/user/$(id -u)/containerd-rootless/api.sock list-ports; fi' || true
412-
# Check container networking from inside (#5030)
413-
limactl shell "$NAME" $sudo $CONTAINER_ENGINE exec nginx sh -c 'wget -qO- http://127.0.0.1:80 2>&1 | head -5 || echo "container-internal wget FAILED"' || true
414-
limactl shell "$NAME" $sudo $CONTAINER_ENGINE exec nginx sh -c 'ss -tlnp 2>/dev/null || netstat -tlnp 2>/dev/null' || true
402+
if ! timeout 3m bash -euxc "until curl -f --retry 15 --retry-connrefused http://127.0.0.1:8080; do sleep 3; done"; then
403+
INFO "=== DEBUG: port forwarding failed (#5030) ==="
404+
# Container state (full inspect, first 80 lines)
405+
limactl shell "$NAME" $sudo $CONTAINER_ENGINE inspect nginx 2>&1 | head -80 || true
406+
# Container logs (stdout+stderr)
407+
limactl shell "$NAME" $sudo $CONTAINER_ENGINE logs nginx 2>&1 || true
408+
# Run nginx in foreground to see actual startup error
409+
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
410+
# What's listening inside the rootlesskit child namespace
411+
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
412+
# Rootlesskit network driver confirmation
413+
limactl shell "$NAME" bash -c 'pgrep -a rootlesskit | head -1' || true
415414
INFO "=== END DEBUG ==="
416415
ERROR "Port forwarding to nginx container on 127.0.0.1:8080 failed"
417416
exit 1

0 commit comments

Comments
 (0)